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';
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';