title: ModalPopupExtender Hault Execution Until Ok is Clicked?
body: <p>Perhaps I misunderstood the control, or very possibly am not implementing it correctly, but I've used a ModalPopupExtender much like I'd like to use a MessageBox in desktop development.  The problem I'm running into is that once I call the Show() method of the ModalPopupExtender it continues to execute the server side code despite the fact that the user has not yet clicked the button set as the OkControlID.  Is this the normal behavior, and or is there a way to hault code execution until the OkControlID has been clicked.  To specify, I don't want to create another event in the button click handler as this popup is inline.  Here is my code - any advice is appreciated.</p>
  
  <p>My Control:</p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ModalMessage.ascx.cs" Inherits="LB.ModalMessage" %&gt;
  &lt;asp:Button ID="btnPopup" runat="server" style="display: none;"/&gt;
  
  &lt;ajaxToolkit:ModalPopupExtender ID="ModalMessageExtender" runat="server"
  OkControlID="btnOkay" PopupControlID="Panel1"
  TargetControlID="btnPopup" BackgroundCssClass="modalPopupBG"&gt;
  &lt;/ajaxToolkit:ModalPopupExtender&gt;
  
  &lt;asp:Panel CssClass="whitebubble" ID="Panel1" style="display: none; max-width:400px;" runat="server"&gt;
  &lt;div style="padding:5px 5px 35px 5px;"&gt;
      &lt;asp:Label ID="lblMessage" Font-Size="Medium" runat="server" ForeColor="Black"/&gt;
      &lt;br /&gt;
      &lt;asp:Button runat="server" Text="Ok" Width="75px" Height="30px" ID="btnOkay" CssClass="modalButton gray modalButton"/&gt;
  &lt;/div&gt;
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>The control code behind:</p>
  
  <pre><code>    public void ShowMessage(string message)
      {
          this.lblMessage.Text = message;
          ModalMessageExtender.Show();
      }
  </code></pre>
  
  <p>My content page:</p>
  
  <pre><code>&lt;%@ Register Src="~/ModalMessage.ascx" TagName="ModalMessage" TagPrefix="mm" %&gt;
  &lt;mm:ModalMessage runat="server" ID="mpeMessage"/&gt;
  </code></pre>
  
  <p>My content code behind:</p>
  
  <pre><code>mpeMessage.ShowMessage("Please enter a username before attempting to reset your password.");
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  Sorry for the lack of clarity - let me make my question more clear.  If I do the following:</p>
  
  <pre><code>mpeMessage.ShowMessage("Please enter a username before attempting to reset your password.");
  Response.Redirect("Register.aspx");
  </code></pre>
  
  <p>The redirect occurs and the ModalPopupExtender never gets shown.  I'm somewhat new to web development so please forgive me if I'm using incorrect terminology.  But essentially, I want the execution of code in the code behinds to wait for the user to click "Ok".  I'm trying to replace something like this:</p>
  
  <pre><code>ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('Your new account has been created!'); window.location='" + continueUrl + "';", true);
  </code></pre>
  
  <p>With something a little nicer looking, and since I'm already doing a postback anyway, I thought calling the ModalPopupExtender programmatically would be fine.  Hopefully this clears up my question.  Thank you all for your responses so far.</p>