首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 ><asp:UpdatePanel >在表<tr>中不工作?

<asp:UpdatePanel >在表<tr>中不工作?
EN

Stack Overflow用户
提问于 2013-02-22 22:35:49
回答 3查看 10.8K关注 0票数 6

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

代码语言:javascript
复制
<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>

事件会触发按钮和复选框,但整个页面将被刷新。谢谢你的帮助。

EN

回答 3

Stack Overflow用户

发布于 2014-06-20 08:13:17

为了正确地工作,UpdatePanel需要呈现一个div或span。由于这两个元素都不能在表行之间呈现,所以UpdatePanel没有一个占位符来呈现回发响应html,因此它无法工作。

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

票数 5
EN

Stack Overflow用户

发布于 2015-04-05 12:09:03

代码语言:javascript
复制
<asp:ScriptManager ID="scm" runat="server">
</asp:ScriptManager>
<fieldset>
<legend>Truck Master Entry Form</legend>
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<table cellpadding="2" cellspacing="1">
<tr>
                    <td align="right">
                        Truck no :
                    </td>
                    <td align="left">
                        <asp:TextBox ID="truckno" runat="server" Width="120px" Height="20px" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        Size :
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="drptrucksize" runat="server" Width="120px" Height="20px" DataValueField="WEIGHT"
                            DataTextField="SIZE" OnSelectedIndexChanged="drptrucksize_SelectedIndexChanged"
                            AutoPostBack="true" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        Type :
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txttrucktype" runat="server" Width="120px" Height="20px" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        Weight :
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtweight" runat="server" Width="120px" Height="20px" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        &nbsp;
                    </td>
                    <td align="left">
                        <asp:Button ID="btnsave" runat="server" Text="Save" Width="100px" Height="50px" />
                        <asp:Button ID="btncancel" runat="server" Text="Cancel" Width="100px" Height="50px" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
票数 0
EN

Stack Overflow用户

发布于 2015-07-01 11:04:57

更新面板需要放在表之外。看

穆罕默德·沙纳瓦兹的密码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15034359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档