I have an UpdatePanel control in my ASP.NET application (actually several, but that’s not the concern).
<asp:UpdatePanel ID="UpdatePanelDetail" runat="server" UpdateMode="Conditional">
<ContentTemplate>
...More code here
Inside the panel, there exists an asp:Table object:
<asp:Table ID="tblGIFs" runat="server"></asp:table>
This table gets programmatically generated via some code from codebehind:
TableRow htr = new TableRow();
TableCell htc = new TableCell();
...<snip>
tblGIFs.Rows.Add(htr)
And that’s all fine, except in one of the cells I am trying to add a button (with an image):
htc3.Text = "<input ID=\""+ii.Value+"\" OnClick = \"btnGIFSearch(this)\" type=\"image\" value=\"/Image/Fiu.png\" />";
When this image is clicked, the onclick fires fine, but the entire UpdatePanel gets refreshed (and consequentually, the asp:Table disappears).
If I use a type="button", it works completely fine and there’s no issue with refreshing/losing the content in the table.
I’ve run the page with breakpoints on every location that I’m touching the table from codebehind to no avail, there’s really nothing more that I can see that could cause the UpdatePanel to be cleared programtically.
Anyone seen similar behavior with these tags/controls and any idea of a resolution? A workaround is obviously using type=button and just styling the button, but I rather not do that if I can get type=image behaving correctly.
Solved with dynamically created controls.