In other words, let's say I have a bunch of divs and they're all nested under one div.
Can I do something on the outer div so that I don't have to write runat="server" on each of the inner divs, but still access them by id from my code-behind?
In other words, let's say I have a bunch of divs and they're all nested under one div.
Can I do something on the outer div so that I don't have to write runat="server" on each of the inner divs, but still access them by id from my code-behind?
Sorry to confirm your findings, but all .NET controls accessed in the code-behind must have runat="server"
and parent controls don't cascade them down like ViewState settings do.
Yeah, it's a problem. But if you want just to do something not too complex with inner divs, for example to change the color or something like that you could try to change the InnerHtml property:
<div id="divTest" runat="server">
<div id="test1" style="color:black">test1</div>
<div id="test2" style="color:black">test2</div>
</div>
protected void Page_Load(object sender, EventArgs e)
{
divTest.InnerHtml = divTest.InnerHtml.Replace("black", "blue");
}
The other way is to use jQuery to get every control.