UserControl AutoRenaming - Textbox versus Label

G

Grant Merwitz

Hi

I am trying to use JavaScript to change asp controls client side.

Now when creating a User Controls, controls that run at server are renamed
with the control tag name.

So if i make a control with an asp:TextBox with id 'tb'.
I then place this control into a webform with the tag UC1, the control is
then named 'UC1:tb'

Now to set this in JavaScript, i simply call tb.UniqueId - and this solves
this issue.

But now TextBoxes and Labels don't seem to work the same.

As in the above example, a textbox called 'tb' is renamed 'UC1:tb'
However a label called 'lbl' becomes 'UC1_lbl'.
Though the UniqueId produces 'UC1:lbl' - so i get a JavaScript error.

To overcome this i go lbl.UniqueId.Replace(":lbl", "_lbl");

Why is this happening?
Is there something I'm missing?

Thanks for any help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top