ASP.NET Find Control with only part of the UniqueID
So I have a situation where we are trying to reduce the page size. My job is to remove as much of the uniqueID's in the markup as possible.
This is where I'm having a problem: I have a value
which is "innerContent$wizard$myTextBox"
and its UniqueID
is ctl00$ctl00$content$innerContent$wizard$myTextBox
. I have a call on the page page.FindControl(value)
which returns null because I only have half the UniqueID
So my question is: How can I use FindC开发者_如何学Control()
with only half the UniqueID
? I'm certain that the value
is unique for the page. (i.e there is no other UniqueID
ending with this value.)
Which half do you get?
If you are using asp.net 4.0, set the ClientIDMode="Static"
Link regarding ClientIDMode
Here is another one that talks about Predictable, but briefly goes over others
Why do you have to use the Page's find control method? Usually you would use the findcontrol method of the parent control or naming contained and pass the Id in the mark up rather than the uniqueId.
精彩评论