更新面板渲染表行错误

jwa*_*ech 6 asp.net updatepanel asp.net-ajax

当我的asp.net AJAX更新面板更新时,我遇到了一个问题,它在我的表顶部而不是在它下面所属的位置呈现内容是我的代码:

<tr>
   <td>
   </td>
   <td>
      <asp:CheckBox ID="ddCheckbox" runat="server" Text="Checkbox"
           AutoPostBack="true" OnCheckedChanged="ddCheckboxChanged" />
   </td>
</tr>

    <asp:UpdatePanel ID="uxUpdatePanel" runat="server" RenderMode="Inline" UpdateMode="Conditional">
       <ContentTemplate>
          <tr>
             <td>
               Some Field:
             </td>
              <td>
                 <asp:TextBox ID="ddSomeField" runat="server" />
              </td>
            </tr>
          </ContentTemplate>
          <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ddCheckbox" EventName="CheckedChanged" />
          </Triggers>
    </asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)

在我的服务器端事件中,我只是启用/禁用文本框.

Mar*_*ger 8

1)创建自定义updatepanel控件(从SingingEels复制/粘贴)

2)将此自定义updatepanel控件与属性一起使用 RenderedElement="TBODY"

3)按照以下方式嵌套你的桌子:

<TABLE>
  <TR>
    <TD>outside updatepanel</TD>
  </TR>
  <SingingEels:SemanticUpdatePanel ID="myUpdatePanel" runat="server" RenderedElement="TBODY">
    <ContentTemplate>
      <TR>
        <TD>inside updatepanel - 1th row</TD>
      </TR>
      <TR>
        <TD>inside updatepanel - 2nd row</TD>
      </TR>
      <TR>
        <TD>inside updatepanel - last row</TD>
      </TR>
    </ContentTemplate>
  </SingingEels:SemanticUpdatePanel>
  <TR>
    <TD>outside updatepanel</TD>
  </TR>
</TABLE>
Run Code Online (Sandbox Code Playgroud)


Jim*_*kus 0

您是否已完成查看源代码以确认它确实在 HTML 本身的该位置呈现它?如果表格格式不正确,浏览器有时会在表格外部呈现标签。它可能看起来在 HTML 本身中被正确定义,但缺少结束标记等可能会导致它以这种方式呈现。