An ASP.NET Button Click Event Is Not Firing
Solution 1:
The problem here is that jQuery-UI creates the dialog outside of the <form>
element, so clicking on it never submits the form.
To get around this, rather than create a click event manually, you can just move the dialog <div>
back into the form. I did a quick search and the answer to this question already covers the issue.
So you just need to make this change:
<script>
// increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 1000;
$(function () {
var dialog = $("#dialog").dialog({
autoOpen: false,
show: "blind",
hide: "explode"
});
// Move the dialog back into the <form> element
dialog.parent().appendTo(jQuery("form:first"));
$("#opener").click(function () {
$("#dialog").dialog("open");
return false;
});
});
</script>
Solution 2:
A turnaround will be to change your button event to a client event, then trigger the server side event from client side.
See Stack Overflow question How to fire a button click event from JavaScript in ASP.NET.
Solution 3:
Beware that this has ramifications when using a iFrame in your dialog. Moving a div with a iFrame in it causes that iFrame to post twice or more. If you have implemented this, I would check to see if this is true in your case. I have posted a work-around that I found here: https://stackoverflow.com/a/24663205/3334255
Post a Comment for "An ASP.NET Button Click Event Is Not Firing"