TextBox ID problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a TextBox inside a usercontrol, in the onInit method i put its ID
property to a string value, like this: MyTextBox.ID="test";

but when the user control is renderer into the internet explorer and i see
the source code, i see that <input type text id=_ctl1_test>

Why im getting this if i assign to the ID the value test?
How could i solve it?
 
Josema,

Is it possible that the control has been rendered already to the
response stream? This is the only reason I could think of that this would
do this.

Hope this helps.
 
Hello!

The controls identifier is used to determine the position of the control in
the hierarchical control tree.

The identifier is also, amongst others, used by ASP.NET to determine which
control recieves the postback datawith the same ID from eachother, which is
why ASP.NET renders a hierarchical identifier that is composed of the IDs of
all the ancestor controls plus the ID of your control.

The control is correctly assigned your control and you can retrieve the
control using the "FindControl()" method on the Page and UserControl
classes. If you need to reference the control clientside, you can use the
"UniqueID" property of the control that returns a hierarchical string
identifier for the control.

Does this answer your question? I know it was a bit verbose, but I haven't
seen any ways of actually getting a simple identifier assigned a control.
 
Back
Top