简体   繁体   English

ASP.NET:即使将Visible设置为True,UpdatePanel也不会显示

[英]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. 我在一个aspx页面中有两个更新面板,每个内部都有一个ModalPopupExtender。 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. 我面临的问题是,我已在aspx页面中将Visible属性设置为false,并在需要显示时将其设置为True。 But the UpdatePanel is not showing up even though I have set Visible=True property. 但是即使我设置了Visible = True属性,UpdatePanel也不会显示。

aspx code: aspx代码:

<%--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: 链接按钮,可触发aspx中的modalpopup:

<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. 如果我没有在aspx页面中设置Visible = False属性,则该ModalPopup之一将显示在网页上,并在弹出窗口中插入“确定”按钮,将其留空。

Also, if I have just one UpdatePanel in my aspx page, the popup works perfectly fine without setting Visible property. 另外,如果我的aspx页面中只有一个UpdatePanel,则在不设置Visible属性的情况下,弹出窗口可以很好地工作。 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. 一旦在其下添加另一个UpdatePanel,就会出现此问题(链接中的屏幕截图),在页面加载时,带有“确定”按钮的面板会显示在该面板上。 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. 我只想知道如何在不出现此问题的情况下使多个UpdatePanels正常工作。

我不确定,但是您可以尝试使用style =“ display:none”代替Visible =“ false”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM