Click here to Skip to main content
15,885,932 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
XML
<script type = "text/javascript" >
  $("[id*=btnModalPopup]").live("click", function() {
    $("#modal_dialog").dialog({
      title: "jQuery Modal Dialog Popup",
      buttons: {
        OK: function() {
          $(this).dialog('close');
        }
      },
      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" OnClick="btnModalPopup_Click" />



Above Code Shows J query popup Message.It Works fine. but after popup message i need to execute server Side Code if i Remove Return False from the script it execute the server Side Code But Popup message disappears. It should execute After popup's OK button Click
Posted

1 solution

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...
ASP.NET
<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" />
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900