locked
ModalPopupExtender to act more like alert()? RRS feed

  • Question

  • User-1615261397 posted

    Hey everyone,

    I have a ModalPopupExtender that works great, I was hoping however that there might be a way to have it act a little more like the Javascript alert method so that I could call it in the code behind and have it stop execution of the code wherever I called the show method and have it continue once the ok control was clicked.  I can post my code, but it's a pretty standard implementation...I would just like to call something like response.redirect after it and have it wait for the popup to close before executing it.

     

    Any help would be greatly appreciated.


    Thank you!

    Thursday, October 3, 2013 9:09 PM

Answers

  • User-417640953 posted

    I want to call execution of the modal popup and have it halt the code inline until it returns...in this case until the user clicks "ok". 

    Hi aaj23,

    Thanks for post the issue to asp.net forum.

    Based on your description, I see that you want to show a popup in behind code.

    And you want to get a result message from the popup then decide to execute following behind code.

    I’m sorry to say that we cannot get a result message from client side when executing server code.

    The page or the popup shows after server code execute completely. Based on the page life cycle, we cannot complete it.

    For this issue, I suggest you show popup to client side and do a post back to execute maintain server code.

    You can refer below.

    http://forums.asp.net/t/1363490.aspx

    If any doubt, please feel free to back. Thanks.

     

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 8, 2013 3:23 AM

All replies

  • Thursday, October 3, 2013 11:38 PM
  • User670679149 posted

    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:Button ID="btnShow" runat="server" Text="Show Modal Popup" />

    <!-- ModalPopupExtender -->
    <cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="btnShow"
    CancelControlID="btnClose" BackgroundCssClass="modalBackground">
    </cc1:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" style = "display:none">
    This is an ASP.Net AJAX ModalPopupExtender Example<br />
    <asp:Button ID="btnClose" runat="server" Text="Close" />
    </asp:Panel>
    <!-- ModalPopupExtender -->
    </form>


    in code behind:
    write:

    if(textbox1.text!="YourCondition")
    {
    mp1.Show();
    }
    else
    {
    Response.Redirect("Form2.aspx");
    }

    Friday, October 4, 2013 12:04 AM
  • User-1615261397 posted

    Not sure what this has to do with my question - I don't want multiple "ok" buttons, I want my code to stop running until the user clicks ok...this will not accomplish this.

    Friday, October 4, 2013 6:27 PM
  • User-1615261397 posted

    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:Button ID="btnShow" runat="server" Text="Show Modal Popup" />

    <!-- ModalPopupExtender -->
    <cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="btnShow"
    CancelControlID="btnClose" BackgroundCssClass="modalBackground">
    </cc1:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" style = "display:none">
    This is an ASP.Net AJAX ModalPopupExtender Example<br />
    <asp:Button ID="btnClose" runat="server" Text="Close" />
    </asp:Panel>
    <!-- ModalPopupExtender -->
    </form>


    in code behind:
    write:

    if(textbox1.text!="YourCondition")
    {
    mp1.Show();
    }
    else
    {
    Response.Redirect("Form2.aspx");
    }

     

    This is conditionally redirecting, but still isn't an answer to the issue - I don't want to sometimes redirect, I want to always redirect, but I want to ensure the user clicks "ok" before proceeding to the next page.

    Friday, October 4, 2013 6:28 PM
  • User-1615261397 posted

    To clarify a little - I used to use "MessageBox.Show()" or "Window.ShowDialog()" for this same purpose - I want to call execution of the modal popup and have it halt the code inline until it returns...in this case until the user clicks "ok".  Hopefully that makes sense.

    Friday, October 4, 2013 6:29 PM
  • User-417640953 posted

    I want to call execution of the modal popup and have it halt the code inline until it returns...in this case until the user clicks "ok". 

    Hi aaj23,

    Thanks for post the issue to asp.net forum.

    Based on your description, I see that you want to show a popup in behind code.

    And you want to get a result message from the popup then decide to execute following behind code.

    I’m sorry to say that we cannot get a result message from client side when executing server code.

    The page or the popup shows after server code execute completely. Based on the page life cycle, we cannot complete it.

    For this issue, I suggest you show popup to client side and do a post back to execute maintain server code.

    You can refer below.

    http://forums.asp.net/t/1363490.aspx

    If any doubt, please feel free to back. Thanks.

     

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 8, 2013 3:23 AM