locked
modalpopupextender is popup in both condition RRS feed

  • Question

  • User29410129 posted

    I am trying to implement  modalpopupextender but now problem is that panel is visible in both condition. but my target is that when modalpopupextender  visible when condition true. I am trying in this way.

           protected void btn_mark_favorite_Click(object sender, EventArgs e)
            {
                try
                {
                    if (UserID != 0)
                    {
    
                        ModalPopupExtender2.Show();
                        Panel1.Visible = false;
    
                    }
                    else
                    {
                        Response.Redirect("Home.aspx");
                        ModalPopupExtender2.Show();
                    }
                }
                catch (Exception ex)
                { }
            }
                     <asp:ModalPopupExtender ID="ModalPopupExtender2" TargetControlID="btn_mark_favorite" runat="server" PopupControlID="Panel1" BackgroundCssClass="modalBackground"  CancelControlID="btn_cancle_2"></asp:ModalPopupExtender>
                       <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" style = "display:none">
                          <br />
                           <p>Login first then try to favorite!</p>
                           <asp:Button ID="btn_cancle_2" runat="server" Text="Cancle"  BackColor="#0066ff" ForeColor="White" Font-Bold="true" Font-Names="Tahoma" Height="25" Width="70" BorderStyle="None" OnClick="btn_cancle_2_Click"   />
                        </asp:Panel>



    Monday, January 11, 2016 7:52 AM

Answers

  • User61956409 posted

    Hi DanyalHaider,

    You specify Panel1 as PopupControl of ModalPopupExtender, so the content in Panel1 will be displayed in modal popup if ModalPopupExtender2 show. Why do you want to set Visible property of Panel1 to false? If you would not like to show Panel1, why do you call show() method to display modal popup? Besides, it seems that it doesn’t enable us to set Visible property of Panel1 when ModalPopupExtender2 is showing, do you get this error?

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 12, 2016 8:30 AM

All replies

  • User177399542 posted

    Try this:

    Panel1.Attributes.Add("style", "display:none");

    Monday, January 11, 2016 8:52 AM
  • User61956409 posted

    Hi DanyalHaider,

    You specify Panel1 as PopupControl of ModalPopupExtender, so the content in Panel1 will be displayed in modal popup if ModalPopupExtender2 show. Why do you want to set Visible property of Panel1 to false? If you would not like to show Panel1, why do you call show() method to display modal popup? Besides, it seems that it doesn’t enable us to set Visible property of Panel1 when ModalPopupExtender2 is showing, do you get this error?

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 12, 2016 8:30 AM