can't get clientid of .net label in a JS file

D

Deere

I have an asp:label with an id='qty' inside a GridView.

I'm wanting to get the proper ClientID of it inside a JS file so I
can assign a value to it.

I can successfully do it manually by viewing the rendered page source
which shows it as 'GridView1_ctl02_qty' and then constructing the
following


document.getElementById("GridView1_ctl02_qty").innerText = " ( " +
mySplitResult[0] + " )"


But I can't get the server rendering of the label ID by requesting it
in the js
file.. I've tried several variations.....
var idd1=document.getElementById('<%=GridView1.qty.ClientID%>')
var idd2=document.getElementById('<
%=GridView1.FindControl("qty").ClientID%>');
var idd3=document.getElementById('<%=qty.ClientID%>')
var idd4=document.getElementById('<%=GridView1$qty.ClientID%>')


I can though assign a value to a text box right beside the same label
contol ie.. < input type ="text" id="qtyy">
and not have to get the server id rendering as below works fine

document.getElementById("qtyy").value = " ( " + mySplitResult[0] +
" )"


can someone point out my error.. or where I need to look


thanks
 
T

Thomas 'PointedEars' Lahn

Deere said:
I have an asp:label with an id='qty' inside a GridView.

I'm wanting to get the proper ClientID of it inside a JS file so I
can assign a value to it.
[...]
I've tried several variations.....
var idd1=document.getElementById('<%=GridView1.qty.ClientID%>')
[...]
can someone point out my error.. or where I need to look

You need to look at the *generated*, *client-side* source code.


PointedEars
 
D

Deere

You need to look at the *generated*, *client-side* source code.

PointedEars

I did ie..."I can successfully do it manually by viewing the rendered
page source
which shows it as 'GridView1_ctl02_qty' and then constructing the
following.... "

Since the label is in gridview I need to assign a value dynamicly as
I dont know what gridview row will be clicked.

thanks
mark
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top