【问题标题】:Two nested update panels on same aspx page同一 aspx 页面上的两个嵌套更新面板
【发布时间】:2017-11-09 04:36:51
【问题描述】:

我在 apsx 页面上有两个嵌套的 UpdatePanel 控件。外层用于整个页面并显示“正在加载页面...”img,而内层的目的是在下拉列表 selectedIndexChanged 上加载网格

我收到此错误,但两者的名称不同: JavaScript 运行时错误:Sys.InvalidOperationException:无法将具有相同 id 'cphMainContent_Updprog3' 的两个组件添加到应用程序中。

请指导。代码结构如下:

     <asp:content id="HeaderContent" runat="server" contentplaceholderid="head">

    <script language="javascript" type="text/javascript">
            function showProgress() {
                var updateProgress = $get("<%=Updprog3.ClientID %>");
                updateProgress.style.display = "block";
            }

        </script>
    </asp:content>

    <asp:content id="BodyContent" runat="server" contentplaceholderid="cphMainContent">
        <div style="padding-left:36px; padding-top:10px;">
            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
    <table align="left">

           <tr>
                <td style="border: none; width:120px">
                    Call Category Group:
                </td>
                <td>
                    <asp:DropDownList ID="ddlGroup" runat="server" 
                        onChange="javascript:showProgress()"
                        OnSelectedIndexChanged="ddlGroup_SelectedIndexChanged" Width="400px">
                        <asp:ListItem Value="-1">--- Select Group ---</asp:ListItem>
                        <asp:ListItem Value="Group 1"> Group 1</asp:ListItem>
                        <asp:ListItem Value="Group 2">Group 2</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>

      <!--2nd update panel-->
    <asp:UpdatePanel ID="UpdPnl" runat="server" UpdateMode="Conditional">
       <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ddlCallCategoryGroup" EventName="SelectedIndexChanged"/>
        </Triggers>
    <ContentTemplate>

    <asp:GridView ID="gridView1" runat="server">
    </asp:GridView>
    </ContentTemplate>
    </asp:UpdatePanel>

    <asp:Panel runat="server" ID="pnlgvSecondLevelLoading" CssClass="modalwindow">
    <asp:UpdateProgress ID="Updprog3" runat="server" AssociatedUpdatePanelID="UpdPnl">
        <ProgressTemplate>
                        <table>
                        <tr>
                            <td align="right" width="35%">
                                <asp:Image ID="imgSubCallCategory_Wait3" runat="server" ImageUrl="ProjectImages/Wait_Small.gif" />
                            </td>
                            <td width="2%">
                            </td>
                            <td align="center" width="73%">
                                Loading data . . .
                            </td>
                        </tr>
                    </table>

        </ProgressTemplate>
    </asp:UpdateProgress>
    </asp:Panel>

    <asp:Panel runat="server" ID="pnlLoading" CssClass="modalwindow">
        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div class="container2">
                    <div class="content">
                        <br />
                        <table>
                            <tr>
                                <td align="right" width="35%">
                                    <asp:Image ID="imgSubCallCategory_Wait2" runat="server" ImageUrl="ProjectImages/30-1.gif" />
                                </td>
                                <td width="2%">
                                </td>
                                <td align="center" width="73%">
                                    Loading Page . . .
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </asp:Panel>
         </ContentTemplate>
        </asp:UpdatePanel> 
    </div>
</asp:content>

【问题讨论】:

  • 你的脚本管理器在哪里?
  • 它在母版页中。 UpdatePanel1 已经存在了一段时间。我现在正在添加 UpdPnl,因为网格需要很长时间才能加载并面临问题
  • 请显示母版页的标记或至少显示脚本管理器。
  • ScriptManager 不是问题,因为应用程序一直在使用一个 UpdatePanel跨度>

标签: c# asp.net gridview updatepanel updateprogress


【解决方案1】:
<asp:ScriptManager ID="WebApp" runat="server" AsyncPostBackTimeout="36000" ScriptMode="Release"></asp:ScriptManager>

【讨论】:

  • 实际上,我们正在使用一个可供所有应用程序全局使用的母版页,我无法更改它。顺便说一句,ScriptMode="Release" 是做什么的?它是否将应用程序设置为发布模式而不是调试?
  • ScriptMode 控制将哪些版本的客户端脚本发送到浏览器。如果您与多个应用程序共享母版页(什么?),您需要验证此更改不会影响其他页面,但除非您有特定原因,您需要使用 .debug.js 文件而不是标准的 . js版本应该没问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-15
相关资源
最近更新 更多