clicking on a button clientSide does not cause postback
Posted
by Andreas Niedermair
on Stack Overflow
See other posts from Stack Overflow
or by Andreas Niedermair
Published on 2010-05-31T11:30:19Z
Indexed on
2010/05/31
11:32 UTC
Read the original article
Hit count: 225
see this example:
<form runat="server">
<asp:Button runat="server" ID="btFoo" Text="asp.net button" />
<button id="btFoo2">open modal</button>
<script type="text/javascript">
$(document).ready(function() {
var btFoo = $('#<%= this.btFoo.ClientID %>');
btFoo.click(); // this will work and cause a postback
btFoo.click(function() {
alert('click triggered');
});
var dialog = $('<div/>');
dialog.text('please click yes');
dialog.dialog({
autoOpen: false,
open: function() {
var widget = dialog.dialog('widget');
widget.appendTo($('form'));
},
buttons: {
'YES': function() {
btFoo.click(); // this will cause a click, but no postback??!!
}
}
});
var btFoo2 = $('#btFoo2');
btFoo2.click(function() {
dialog.dialog('open');
return false;
});
});
</script>
</form>
any help would be appreciated, to get this example working!
© Stack Overflow or respective owner