更新Panel渲染表行错误
当我的 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>
在我的服务器端事件中,我只是启用/禁用文本框。
I am having an issue when my asp.net AJAX Update Panel updates it renders the contents at the top of my table rather than in the place it belongs below is my code:
<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>
In my server side event I am just enabling/disabling the textbox.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
1)创建自定义 updatepanel 控件(从 SingingEels 复制/粘贴)
2)使用此自定义具有属性
RenderedElement="TBODY"
的 updatepanel 控件3) 嵌套表格,如下所示:
1) create a custom updatepanel control ( copy/paste from SingingEels )
2) use this custom updatepanel control with an attribute
RenderedElement="TBODY"
3) nest your table as follow:
我相信这是由于您嵌套更新面板的方式所致。 如果您将更新面板更改为 td 的子级,而不是表的子级:
您应该全部修复。
I believe it's due to how you are nesting the Update panel. If you change the update panel to be a child of the td, rather than of the table:
You should be all fixed up.
您是否已完成查看源代码以确认它确实在 HTML 本身内的该位置呈现它? 如果表格格式不正确,浏览器有时会在表格外部呈现标签。 它可能看起来在 HTML 本身中被正确定义,但缺少结束标记等可能会导致它以这种方式呈现。
Have you done a view source to confirm that it is actually rendering it in that location within the HTML itself? Browsers will sometimes render tags outside of the table if the table is malformed. It may appear to be defined properly in the HTML itself, but a missing closing tag etc may cause it to render that way.
当更新面板回发到服务器时,它会回发所有内容(包括视图状态)。 为什么不直接做一些简单的 JavaScript 呢? 这会更有效率。
When the Update Panel posts back to the server, it posts everything back (including viewstate). Why not just do some simple javascript? It would be much more efficient.