473,624 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to have javascript access the text of a checkbox created by .Net 2.0

Hi,

I have a page done in ASP .NET 2.0 that uses an asp:CheckBox. .Net
renders the CheckBoxin the following manner:
<input id="_ctl0_Body_ _players__ctl0_ _player" type="checkbox"
name="_ctl0:Bod y:_players:_ctl 0:_player" /><label
for="_ctl0_Body __players__ctl0 __player">SomeL astName, SomeFirstName </
label>

How do I access the value of the label for that CheckBox using
javascript? There is no id, tag or anything else to tie it into
something that I can grab.

Any and all help is appreciated.

Thanks,

David

Jun 6 '07 #1
2 1919

dnaumow...@gmai l.com wrote:
There is no id, tag or anything else to tie it into
something that I can grab.
Hi,
Here is the "label" tag. It is not worse then any other tag.
You can get all elements of the "label" type and find among then an
element that refers to the given checkbox.
Example:

function getLabelValue(c heckboxClientID )
{
var labels = document.getEle mentsByTagName( "label");
for(var i=0; i<labels.length ; i++)
{
if (labels[i].htmlFor == checkboxClientI D)
return labels[i].innerHTML;
}
return null;
}
Regards, Mykola
http://marss.co.ua

Jun 6 '07 #2
On Jun 6, 6:40 am, dnaumow...@gmai l.com wrote:
There is no id, tag or anything else to tie it into
something that I can grab.
All server controls have an ID.

The Client ID of your CheckBox is _ctl0_Body__pla yers__ctl0__pla yer

To refer to that control from the client script you can use the
ClientID property,

for example

var chk = document.getEle mentById('<%=pl ayer.ClientID%> ');
// where 'player' is the name of your CheckBox control

Jun 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1532
by: Robin Becker | last post by:
I'm trying to fix a problem in IE 5.2 javascript on mac OS 10.2. Basically the problem is that we're writing dynamic form elements and these don't seem to be recognized by the form. The code that does the writing looks like /////////////////////////////////////// var IE4 = document.all ? 1 : 0; var NS4 = document.layers ? 1 : 0; var DOM = (!IE4 && document.getElementById) ? 1 : 0;
4
7286
by: Steph | last post by:
Hello, Can someone tell me the script to use for having a change on the same page when using checkbox function ? For example, i would to check one condition and display dynamically a button if the condition is checked on the same page. Thanks in advance for your help
3
6275
by: bhanubalaji | last post by:
hi, I am unable to disable the text(label) in javascript..it's working fine with IE,but i am using MOZILLA.. can any one help regarding this.. What's the wrong with my code? I am sending my code here.. Thanks in Advance... Regards
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8348
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.