Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
  • The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.
  • The page you are viewing does not exist in the .NET Core 3.0+ platform documentation. This link will take you to the parent topic of the current section.

SupportClientScriptsExtensions.SetClientScript(ISupportClientScripts, String, Boolean) Method

Assigns a JavaScript code to the current Action. This code is executed in a browser when a user clicks the Action.

Namespace: DevExpress.ExpressApp.Actions

Assembly: DevExpress.ExpressApp.Web.v20.2.dll

NuGet Package: DevExpress.ExpressApp.Web

Declaration

public static void SetClientScript(
    this ISupportClientScripts action,
    string script,
    bool processOnServer
)

Parameters

Name Type Description
action DevExpress.ExpressApp.Actions.ISupportClientScripts

An ISupportClientScript object specifying an Action.

script String

A string specifying the JavaScript code to be executed when a user clicks the current Action.

processOnServer Boolean

true, if the Action should be processed on the server in addition to the JavaScript execution; otherwise, false.

Remarks

Use this overload to assign a custom script to a specified Action. The processOnServer parameter controls whether the Action’s default code is processed on the server.

processOnServer value Special conditions Result
true - When an end user clicks a specified Action, the custom script is executed on the client-side, and then the Action’s default code is executed on the server.
true The client script also returns true. When an end user clicks a specified Action, the custom script is executed on the client-side. The server does not process the Action’s default code.
false - When an end user clicks a specified Action, the custom script is executed on the client-side. The server does not process the Action’s default code.

The following example demonstrates how you can use the SetClientScript method in your code.

using System.Web;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
// ...
public class SampleController : ViewController {
  public SampleController() {
    SimpleAction action = 
    new SimpleAction(this, "ActionWithScript", PredefinedCategory.Edit);
    action.SetClientScript(string.Format
      ("alert('About to execute the {0} action.');", 
      HttpUtility.JavaScriptStringEncode(action.Caption)), false);
  }
}
See Also