Ben Junior Ben Junior - 1 year ago 276
C# Question

DevExpress component Button for asp.net MVC - Change the ButtonClick event using Jquery

I'm trying to change the original button click event as in the code below, but the alert('hello') message fires when the view is displayed and not when the button is clicked:

<div>

<!-- THIS IS A SHARED VIEW -->
@Html.DevExpress().Button(settings =>
{
.....
settings.Name = "btnSaveDetails";
settings.EnableClientSideAPI = true;
settings.ClientSideEvents.Click = "DoSomething()";
}).GetHtml()
<!-- END SHARED VIEW -->

</div>
<script>
btnSaveDetails.ButtonClick = alert('hello');
</script>

Answer Source

Not sure how you know the button name is btnSaveDetails but the following simple jQuery on document ready function should work.

$(function(){ 
    $('#btnSaveDetails').on('click', function(){ 
       alert('hello'); 
    }); 
 );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download