Anirudh Srinivas
Anirudh Srinivas

Reputation: 11

ASP.NET: UpdatePanel not displaying even when Visible set to True

I have two Update Panels in an aspx page and one ModalPopupExtender inside each of them. The problem I am facing is that, I have set the Visible property to false in the aspx page and set it to True when it needs to be displayed. But the UpdatePanel is not showing up even though I have set Visible=True property.

aspx code:

<%--Request closed --%>
<asp:UpdatePanel ID="udpModalReqClose" runat="server" Visible="false">
    <ContentTemplate>
        <div style="display:none">
            <asp:Button ID="btnDummyButton_ReqClose" UseSubmitBehavior="true" runat="server" Text="DummyButton" Style="display: none;" />
        </div>
        <asp:Panel ID="pnlCloseReq" runat="server" BackColor="White" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px">
            <div>
                <table id="Table24" runat="server" border="0" cellpadding="4" cellspacing="10" width="400px">
                    <tr>
                        <td align="center">
                            <asp:Label ID="lblcloseSuccessOPR" runat="server" Font-Bold="true" ForeColor="Red" /> 
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px;"></td>
                    </tr>
                    <tr>
                        <td align="center">
                            <asp:Button ID="btn_okclose" runat="server" SkinID="btnSearch" CssClass="btnSearch" OnClick="btnPOCPIRedirect_Click"
                                        CausesValidation="false" align="center" Text="OK" Width="65px" />
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px;"></td>
                    </tr>
                </table> 
            </div>
        </asp:Panel>
        <cc1:ModalPopupExtender ID="mpeClosedSuccess" runat="server" PopupControlID="pnlCloseReq" TargetControlID="btnDummyButton_ReqClose" 
            BackgroundCssClass="modalPopup1" DropShadow="true" BehaviorID="mpe">
        </cc1:ModalPopupExtender>
    </ContentTemplate>
</asp:UpdatePanel>

<%--Request declined --%>
<asp:UpdatePanel ID="udpModalReqDecline" runat="server" Visible="false">
    <ContentTemplate>
        <div style="display:none">
            <asp:Button ID="btnDummyButton_ReqDecline" UseSubmitBehavior="true" runat="server" Text="DummyButton" Style="display: none;" />
        </div>
        <asp:Panel ID="pnlRequestDecline" runat="server" BackColor="White" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px">
            <div>
                <table id="Table17" runat="server" border="0" cellpadding="4" cellspacing="10" width="400px">
                    <tr>
                        <td align="center">
                            <asp:Label ID="lblRequestDecline" runat="server" Font-Bold="true" ForeColor="Red" /> 
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px;"></td>
                    </tr>
                    <tr>
                        <td align="center">
                            <asp:Button ID="Button4" runat="server" SkinID="btnSearch" CssClass="btnSearch" OnClick="btnPOCPIRedirect_Click"
                                        CausesValidation="false" align="center" Text="OK" Width="65px" />
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px;"></td>
                    </tr>
                </table> 
            </div>
        </asp:Panel>
        <cc1:ModalPopupExtender ID="mpeRequestDecline" runat="server" PopupControlID="pnlRequestDecline" TargetControlID="btnDummyButton_ReqDecline" 
            BackgroundCssClass="modalPopup1" DropShadow="true" BehaviorID="mpe">
        </cc1:ModalPopupExtender>
    </ContentTemplate>
</asp:UpdatePanel>

Link buttons which triggers the modalpopup in aspx:

<ItemTemplate>
      &nbsp;<asp:LinkButton ID="LinkButton3" OnClick="lnkCloseReleaseHL" runat="server"
                                                Text="Close"></asp:LinkButton>&nbsp;
</ItemTemplate>

<asp:TemplateColumn HeaderText="Decline">
       <ItemTemplate>
           &nbsp;<asp:LinkButton ID="lnkDeclineHLRelease" runat="server" OnClick="lnkDeclineHLRelease_Click">Decline All</asp:LinkButton>&nbsp;
       </ItemTemplate>

Code behind:

public void lnkCloseReleaseHL(object sender, System.EventArgs e)
{
      udpModalReqClose.Visible = true;
      string successMsg = "Request has been closed Succesfully.";
      lblcloseSuccessOPR.Text = successMsg;
      mpeClosedSuccess.Show();
}

protected void lnkDeclineHLRelease_Click(object sender, EventArgs e)
{
    udpModalReqDecline.Visible = true;
    string successMsg = "Request has been declined.";
    lblRequestDecline.Text = successMsg;
    mpeRequestDecline.Show();
}

If I do not set the Visible=False property in the aspx page, one of the ModalPopup is shown on the webpage, blank with the 'OK' button I have inserted in the popup.

Also, if I have just one UpdatePanel in my aspx page, the popup works perfectly fine without setting Visible property. Once I add another UpdatePanel below it, this problem occurs(screenshot in the link), where the panel with 'OK' button is displayed on page load. Panel appearing on page with the 'OK' button

I tried searching for every possible solutions on the web but nothing has helped me. If someone can please guide me how I can resolve this, it would be of great help. I just want to know how I can make multiple UpdatePanels work without having this issue.

Upvotes: 1

Views: 996

Answers (1)

Mauricio Atanache
Mauricio Atanache

Reputation: 2581

I'm not sure, but you can try using style="display:none" instead of Visible="false"

Upvotes: -1

Related Questions