AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

AdvantageModule Class

Base class for all AdvantageCSP modules. Provides access to page-level properties (domain, language, navigation), script registration, inter-module event broadcasting, caching, and object locking.

Namespace:  AdvantageCMS.Core.Common.BaseClasses
Assembly:  AdvantageCMS.Core (in AdvantageCMS.Core.dll)

Syntax


[SerializableAttribute]
public abstract class AdvantageModule : UserControl

Examples


The following example shows how to create a custom module that inherits from AdvantageModule and uses domain-level site settings, inter-module communication, and script registration:
C#
public class HeroBannerModule : AdvantageModule
{
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (!IsPostBack)
        {
            // Access domain-level settings via SiteSettings
            var settings = SiteSettings<MySiteSettings>();
            string heroTitle = settings.DefaultHeroTitle;

            // Access current domain and language
            var domainName = CurrentDomain.Name;
            var languageCode = CurrentLanguage.CultureCode;

            // Register a script at the bottom of the page
            RegisterBottomScript("hero-init",
                $"<script nonce='{CSPNonce}'>initHero('{heroTitle}');</script>");

            // Broadcast an event so other modules know the hero is loaded
            var args = new Hashtable { { "Title", heroTitle } };
            BroadcastEvent("HeroBannerLoaded", args);
        }
    }

    // Receive events from other modules on the page
    public override void ReceiveEvent(string eventId, Hashtable eventArgs)
    {
        if (eventId == "ThemeChanged")
        {
            string newTheme = eventArgs["Theme"]?.ToString();
            // React to theme changes from another module
        }
    }
}

Inheritance Hierarchy


Object
  Control
    TemplateControl
      UserControl
        AdvantageCMS.Core.Common.BaseClasses..::..AdvantageModule