You have to understand the flow of your code...
Case A:
1. on
click
the dialog created and shown as modal
2.
return false
breaks the normal flow and the click even not sent to the server
Case B:
1. on
click
the dialog created and shown as modal
2. no
return false
so the normal flow sends the click to the server - in this case all your page are re-posted so no dialog anymore
Basically you can call click event of the button using jQuery - the problem is that you are creating a loop, as the client click will be raised too...So the probably simplest way is using two buttons - one for the client and an other (hidden) for the server...
<script type = "text/javascript" >
$("[id*=btnModalPopup]").live("click", function() {
$("#modal_dialog").dialog({
title: "jQuery Modal Dialog Popup",
buttons: {
OK: function() {
$(this).dialog('close');
$("#btnModalPopupServer").click();
}
},
modal: true
});
return false;
}); < /script>
<div id="modal_dialog" style="display: none">
This is a Modal Background popup
</div>
<asp:Button ID="btnModalPopup" runat="server" Text="Show Modal Popup" />
<asp:Button ID="btnModalPopupServer" runat="server" OnClick="btnModalPopup_Click" style="display:none" />