Back to Devexpress

Client-Side Events

aspnetmvc-402313-common-features-client-side-functionality-client-side-events.md

latest3.2 KB
Original Source

Client-Side Events

  • Aug 03, 2025
  • 2 minutes to read

DevExpress ASP.NET MVC Extensions include an advanced client-side API that improves web application efficiency via server-side and client-side processing. Client-side events apply web application logic on the client in response to end user operations.

Use an extension’s ClientSideEvents property to list available client events and to assign JavaScript handler functions to them.

Client-side Event Handler Signature

A client-side event handler signature is similar to the standard server-side version. The default signature is illustrated below.

settings.ClientSideEvents.EventName = "function(s, e){...}";

cshtml
@Html.DevExpress().Button(settings => {
    settings.Name = "btnClear";
    settings.Text = "Clear Text";
    settings.ClientSideEvents.Click = "function(s, e){ textBox1.SetText(''); }";
}).GetHtml()

An event handler function has two parameters:

  • the s parameter represents the client object that raises the event;

  • the e parameter represents the event argument, which typically contains event-specific information.

Note that you should use the s object (instead of an extension’s Name property value) to access the source of an event handler.

cshtml
@Html.DevExpress().GridView(settings => {
        settings.Name = "myGrid";
        settings.ClientSideEvents.RowDblClick = "function(s, e){ 
            // myGrid.StartEditRow(e.visibleIndex);
            s.StartEditRow(e.visibleIndex);
        }";
        // ...
    }).Bind(Model).GetHtml()

How to Assign an Event Handler

For each client-side event that is handled, you must specify a JavaScript function to be executed when the event is triggered. You can assign functions in the following ways.

Note

Register handling JavaScript functions at the top of the page to ensure that the browser executes these scripts before it renders DevExpress ASP.NET components.