Obtaining element ID for client script

K

kw

What is the proper way to get the element ID for a client script?

For example, suppose in the WebControl:
TextBox t=new TextBox;
t.ID=this.ClientID+"X";
....
Then elsewhere we want to access it on the client:
Control.Attributes["OnClick"] =
"javascript:document.getElementById('"+this.ClientID+"X"+"').value=
'test';";

It doesn't work because the textbox ID becomes something like:

TextBox1_X

and the link control looks like this:

javascript:document.getElementById('TextBox1X').value= 'test';
 

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,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top