WebWindow.CustomRegisterTemplateDependentScripts Event

Occurs when ASP.NET Template's scripts are registered.

Namespace: DevExpress.ExpressApp.Web

Assembly: DevExpress.ExpressApp.Web.v18.1.dll

Syntax

public event EventHandler<CustomRegisterTemplateDependentScriptsEventArgs> CustomRegisterTemplateDependentScripts

The event handler receives an argument of the DevExpress.ExpressApp.Web.CustomRegisterTemplateDependentScriptsEventArgs type.

Handle the CustomRegisterTemplateDependentScripts to register custom scripts. The snippet below illustrates how to implement the Controller that subscribes to this event.

public class RegisterCustomScriptsController : Controller {
    private void window_CustomRegisterTemplateDependentScripts(
        object sender, CustomRegisterTemplateDependentScriptsEventArgs e) {
        WebWindow window = (WebWindow)sender;
        e.Handled = true;
        e.Page.ClientScript.RegisterClientScriptResource(GetType(), 
            "MySolution.Module.Web.Resources.TemplateScripts.js");
        e.Page.ClientScript.RegisterClientScriptResource(GetType(), 
            "MySolution.Module.Web.Resources.MoveFooter.js");
    }
    protected override void OnFrameAssigned() {
        base.OnFrameAssigned();
        WebWindow window = Frame as WebWindow;
        if(window != null) {
            window.CustomRegisterTemplateDependentScripts += 
                new EventHandler<CustomRegisterTemplateDependentScriptsEventArgs>(
                    window_CustomRegisterTemplateDependentScripts);
        }
    }
    protected override void OnDeactivated() {
        WebWindow window = Frame as WebWindow;
        if(window != null) {
            window.CustomRegisterTemplateDependentScripts -= 
                new EventHandler<CustomRegisterTemplateDependentScriptsEventArgs>(
                    window_CustomRegisterTemplateDependentScripts);
        }
        base.OnDeactivated();
    }
}

The complete example is available in the FeatureCenter demo.