The generated HTML code for my custom ASP.net server control generates the name attribute for child controls, instead of the id attribute. Something like this :
<span id="GridView2_ctl02_editdis">
<input type="text" name="GridView2$ctl02$editdis$ctl00"/>
</span>
The ID for the custom control itself is apparently proper.
What is even stranger for me, is that the ID does get generated sometimes (I do not know under what conditions). But a FindControl()
with that ID returns null on the server side. FindControl()
with the value of the name attribute works just fine.
Something like this :
<span class="TextBox" id="GridView2_ctl02_editdis">
<input type="text" id="GridView2_ctl02_editdis_ctl00" name="GridView2$ctl02$editdis$ctl00"/>
</span>
For the above, FindControl("GridView2$ctl02$editdis$ctl00")
works fine, FindControl("GridView2_ctl02_editdis_ctl00")
doesn't.
How do I ensure consistent and predictable IDs?