Back to Devexpress

ButtonSettings.ClientSideEvents Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-buttonsettings-39c0882c.md

latest2.8 KB
Original Source

ButtonSettings.ClientSideEvents Property

Gets an object that lists the client-side events specific to the Button.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public ButtonClientSideEvents ClientSideEvents { get; }
vb
Public ReadOnly Property ClientSideEvents As ButtonClientSideEvents

Property Value

TypeDescription
ButtonClientSideEvents

A ButtonClientSideEvents object that allows you to handle the component’s client-side events.

|

Remarks

The ClientSideEvents property provides access to an object of the ButtonClientSideEvents type. This object contains properties whose names correspond to the events available to the Button on the client side. These properties provide the capability to assign handling JavaScript functions to the required client-side events of the Button.

csharp
public ActionResult Index()
{
    return View();
}
public ActionResult Click()
{            
    return View();
}
public ActionResult ButtonAction(int customParameter)
{
    TempData["customParameter"] = customParameter;
    return RedirectToAction("Click");
}
cshtml
@Html.DevExpress().Button(settings =>
{
    settings.Name = "Button";
    settings.Text = "Click";
    settings.ClientSideEvents.Click = "function(s, e) { OnClick(s, s.name, 'test'); }";
    settings.RouteValues = new { Controller = "Home", Action = "ButtonAction", customParameter = 5 };
}).GetHtml()
cshtml
<p>customParameter - @TempData["customParameter"] </p>
javascript
function OnClick(s, e, d) {
    alert('s = ' + s);
    alert('e = ' + e);
    alert('d = ' + d);
}

See Also

Button

Client-Side Functionality

ButtonSettings Class

ButtonSettings Members

DevExpress.Web.Mvc Namespace