c# - <asp :UpdatePanel > doesn't work inside a table <tr>?

标签 c# asp.net ajax

我在获取 <asp:UpdatePanel..> 时遇到问题在 <table>.. <tr> </tr> 内工作结构,我不知道为什么。当 UpdatePanel 被注释掉时一切正常,但是当我取消对 UpdatePanel 的注释时 <tr> </tr> 的内容标记甚至不会出现在 Visual Studio 2010 中。当我运行网页时,此内容会显示,但 UpdatePanel 不起作用。我在这个项目中的其他网页都没有这个问题,但是,我再次使用 <div> s 而不是 <table > 在他们里面。 另一件事。 在我的 MasterPage 中。 这是我的脚本:

<asp:UpdatePanel ID="W9UpdatePanel" runat="server" UpdateMode="Always">
    <ContentTemplate>
        <tr>
          <td colspan="6">
            <div class="branchSetupSectionTitle">W-9 Information:</div>
          </td>
        </tr> 
        <tr>
           <td colspan="2">
             <asp:Button ID="btnDownloadW9Pdf" runat="server" 
             Text="Download W-9"  onclick="btnDownloadW9Pdf_Click" AutoPostBack="True" /> 
             <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator24" 
              runat="server" ControlToValidate="txtFirstPaymentAmount" Display="Dynamic" 
              ErrorMessage="The dollar amount you entered is in the wrong format." 
              ForeColor="Red" ValidationExpression="^\d+(\.\d\d)?$">*</asp:RegularExpressionValidator>--%>
              <asp:CheckBox ID="chkW9FormSubmitted" runat="server" AutoPostBack="True" 
              oncheckedchanged="chkW9FormSubmitted_CheckedChanged" 
              Text=" I have submitted this W-9 Form" />
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
         </tr> 
    </ContentTemplate>
</asp:UpdatePanel>

   </tr>

按钮和复选框都会触发该事件,但会刷新整个页面。 感谢您的帮助。

最佳答案

UpdatePanel 需要呈现一个 div 或 span 才能正常运行。由于这些元素都不能在表格行之间呈现,因此 UpdatePanel 没有占位符来呈现回发响应 html,因此它不起作用。

您的情况的解决方法可能是查看您的页面的哪一部分不需要在更新面板内并将其留在外面。您可以只保留 <td colspan="2"> 的内容在 UpdatePanel 中。

关于c# - <asp :UpdatePanel > doesn't work inside a table <tr>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15034359/

相关文章:

javascript - XMLHttpRequest 无法加载 ZScaler 问题

c# - Ping 不适用于 BackgroundWorker

c# - PayPal API,找到合适的

C# 将字符串放入文本框

c# - 如何在一行代码中转换和使用一个对象?

asp.net - 重新使用现有 Microsoft Identity 用户表时密码(哈希)不匹配

ajax - 如何描述 Web 服务器和 Web 客户端之间的交互?

javascript - 如何通过单击一个按钮将文本框值和 dxDatagrid 所有选定值插入数据库?

c# - 如何在没有死锁的情况下正确读取 c# 进程标准错误流?

c# - 无法加载文件或程序集 'System.Security.Principal.Windows'