locked
Modal Popup Extender doesn't show RRS feed

  • Question

  • User-643157890 posted

    I have a Save button (btnSave) when clicked it would show a popup using Ajax Modal Popup Extender; I also create a prompt message to tell the user that data is saved.
    I wanted to show the popup with the message and then when the user click on "OK", it will redirect the user to the previous page. The codes are following.

    protected void btnSave_Click(object sender, EventArgs e)
        {       Session["Status"] = 1;
                SaveData();
                Session["Button"] = "S";
                lblPanel.Text = "SAVE";
                txtPanel.Text = "Data is saved";
                btnNO.Text = "OK";
                btnYES.Visible= false; //because there is no action; just display a message.
                MPE1.Show();
                if (Session["Role"].ToString() == "1")
                      Response.Redirect("List1.aspx");
                else if (Session["Role"].ToString() == "2")
                      Response.Redirect("List2.aspx");
                else
                      Response.Redirect("List3.aspx");
             }
        }

    The problem is when it reaches to the MPE1.Show(), it doesn't show the popup. It continues to go down to those redirect codes and go back to the previous page (List pages) without showing the popup. Can you please show me what is wrong and how to fix it?

    Thank you. 

    Thursday, July 28, 2016 2:17 PM

Answers

  • User61956409 posted

    Hi newUser15,

    Please modify your code to redirect user on "OK" button click event instead of btnSave click event. The following sample is for your reference.

    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
    <asp:Button ID="btnopen" runat="server" Text="Button" Style="display: none" />
    <asp:ModalPopupExtender ID="MPE1" runat="server" TargetControlID="btnopen" PopupControlID="Panel1"></asp:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server">
        would you like to save data?
        <asp:Button ID="btnyes" runat="server" Text="Yes" OnClick="btnyes_Click" />
        <asp:Button ID="btnno" runat="server" Text="No" />
    </asp:Panel>
    
    protected void btnSave_Click(object sender, EventArgs e)
    {
        MPE1.Show();
    }
    
    protected void btnyes_Click(object sender, EventArgs e)
    {
        if (Session["Role"].ToString() == "1")
            Response.Redirect("List1.aspx");
        else if (Session["Role"].ToString() == "2")
            Response.Redirect("List2.aspx");
        else
            Response.Redirect("List3.aspx");
    }
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 29, 2016 2:32 AM

All replies

  • User61956409 posted

    Hi newUser15,

    Please modify your code to redirect user on "OK" button click event instead of btnSave click event. The following sample is for your reference.

    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
    <asp:Button ID="btnopen" runat="server" Text="Button" Style="display: none" />
    <asp:ModalPopupExtender ID="MPE1" runat="server" TargetControlID="btnopen" PopupControlID="Panel1"></asp:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server">
        would you like to save data?
        <asp:Button ID="btnyes" runat="server" Text="Yes" OnClick="btnyes_Click" />
        <asp:Button ID="btnno" runat="server" Text="No" />
    </asp:Panel>
    
    protected void btnSave_Click(object sender, EventArgs e)
    {
        MPE1.Show();
    }
    
    protected void btnyes_Click(object sender, EventArgs e)
    {
        if (Session["Role"].ToString() == "1")
            Response.Redirect("List1.aspx");
        else if (Session["Role"].ToString() == "2")
            Response.Redirect("List2.aspx");
        else
            Response.Redirect("List3.aspx");
    }
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 29, 2016 2:32 AM
  • User-643157890 posted
    Thanks, Fei Han. I will check and I will let you know.
    Sunday, July 31, 2016 9:11 PM