ActionBaseExtensions.RegisterClientScriptOnExecute(ActionBase, String, String) Method

Register a client script to be executed on an Action execute.

Namespace: DevExpress.ExpressApp.Actions

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

Declaration

public static void RegisterClientScriptOnExecute(
    this ActionBase action,
    string scriptName,
    string script
)
<ExtensionAttribute>
Public Shared Sub RegisterClientScriptOnExecute(
    action As ActionBase,
    scriptName As String,
    script As String
)

Parameters

Type Name Description
ActionBase action

An Action on whose execution a client script will be executed.

String scriptName

A string that is a script name.

String script

A string that is the script to be executed on an Action execution.

You can use the actionParameter variable in a script which has different structure for each Action type:

Note

The RegisterClientScriptOnExecute method does not work with the PopupWindowShowAction. So, if you use this Action, register a script for the dialog window's DialogController.AcceptAction.

The following example demonstrates how to use this method to show a text notification.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Mobile;
//...
public class ClientScriptsController : ViewController {
    private SingleChoiceAction singleChoiceAction;
    public ClientScriptsController() {
        singleChoiceAction = new SingleChoiceAction(this, "ClientSideAction", "");
        singleChoiceAction.Items.Add(new ChoiceActionItem("Item1", "Item 1", null));
        singleChoiceAction.SelectedIndex = 1;
    }
    protected override void OnActivated() {
        base.OnActivated();
        if (((MobileApplication)Application).ClientApplicationCreating) {
            singleChoiceAction.RegisterClientScriptOnExecute("AlertScript", @"  
                DevExpress.ui.notify({   
                    closeOnClick: true,   
                    message: 'ClientSideAction are executed. Selected item: ' + actionParameter.text,  
                    type: 'info'   
                });"
            );
        }
    }
}

If a client script is not registered for an Action, it is processed on server-side by default.

singleChoiceAction.RegisterClientScriptOnExecute("ProcessOnServer", singleChoiceAction.GetProcessActionOnServerScript());

If you want to execute your script and then process the Action on the server-side, call the GetProcessActionOnServerScript method and add the result to your script registration:

singleChoiceAction.RegisterClientScriptOnExecute("AlertScriptWithProcessOnServer", @"  
    DevExpress.ui.notify({   
        closeOnClick: true,   
        message: 'ClientSideAction are executed. Selected item: ' + actionParameter.text,  
        type: 'info'   
});" + singleChoiceAction.GetProcessActionOnServerScript());

See Also