By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,848 Members | 3,202 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,848 IT Pros & Developers. It's quick & easy.

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

P: n/a
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").inn erText = " ( " +
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.Cli entID%>')
var idd2=document.getElementById('<
%=GridView1.FindControl("qty").ClientID%>');
var idd3=document.getElementById('<%=qty.ClientID%>')
var idd4=document.getElementById('<%=GridView1$qty.Cli entID%>')
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
Oct 25 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Deere wrote:
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.Cli entID%>')
[...]
can someone point out my error.. or where I need to look
You need to look at the *generated*, *client-side* source code.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Oct 26 '08 #2

P: n/a
On Oct 26, 6:49*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
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
Oct 28 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.