J
John Dalberg
I am looking at a problem which is preventing my code to get a reference to
any asp control inside a div section which has a runat=server attribute.
This can be reproduced in a simple test:
Create a blank webform and add this html inside the <form> section:
<div id="myDiv" runat=server>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
In the code behind, add this code in the page_load event handler:
foreach (Control c in this.Controls)
{
}
Put a breakpoint on the first curly brace. When the code breaks, look at
the Controls collection in the debugger. One of the controls shows:
{InnerText =
'((System.Web.UI.HtmlControls.HtmlContainerControl)(this.Controls._controls
[1])).InnerText' threw an exception of type 'System.Web.HttpException'}
Inside my loop, I have code to get a reference to the textbox which never
excutes. When I remove the runat=server from the div tag, the exception is
gone.
What am I missing?
TIA.
John Dalberg
any asp control inside a div section which has a runat=server attribute.
This can be reproduced in a simple test:
Create a blank webform and add this html inside the <form> section:
<div id="myDiv" runat=server>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
In the code behind, add this code in the page_load event handler:
foreach (Control c in this.Controls)
{
}
Put a breakpoint on the first curly brace. When the code breaks, look at
the Controls collection in the debugger. One of the controls shows:
{InnerText =
'((System.Web.UI.HtmlControls.HtmlContainerControl)(this.Controls._controls
[1])).InnerText' threw an exception of type 'System.Web.HttpException'}
Inside my loop, I have code to get a reference to the textbox which never
excutes. When I remove the runat=server from the div tag, the exception is
gone.
What am I missing?
TIA.
John Dalberg