Wednesday, March 21, 2012

Trouble when using UpdatePanel between <tr> tags

Hello,

It seems I'm getting trouble when trying to use an updatepanel between a set of <tr> tags:

<table>
<tr>
<atlas:UpdatePanel ID="UpdatePanel1" runat=server Mode=Conditional>
<ContentTemplate>
<td>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack=true OnCheckedChanged="CheckBox1_CheckedChanged" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><%=DateTime.Now %>
</td>
</ContentTemplate>
</atlas:UpdatePanel>
</tr>
</table>

This causes the whole page to post back, not just the portion of the page.

However , When I try to use <asp:Table> tags , everything works fine:

<asp:Table>
<asp:TableRow>
<atlas:UpdatePanel ID="UpdatePanel2" runat="server" Mode="Conditional">
<ContentTemplate>
<asp:TableCell>
<asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><%=DateTime.Now %>
</asp:TableCell>
</ContentTemplate>
</atlas:UpdatePanel>
</asp:TableRow>
</asp:Table>

Is this a bug, or am I required to use <asp:table> tags instead of regular html tags ?

hello.

that is beacuse your html isn't correct. you'll have to put the updatepanel inside the <td> element.


Luis is correct. The UpdatePanels renders either a <div> or a <span> depending on its RenderMode property. It's not valid XHTML to have these tags inside a <tr> - they have to go inside a <td>.

Thanks,

Eilon


From what I've found they could also wrap the <table> if your table is not that big it might be another option.

No comments:

Post a Comment