473,796 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handle RadioButtonList click event by Clientscript

I want to do some client-side operation by click different radiobuttonlist .

I tried to add "onclick" event for each itemlist, by register startup
clientside javascript. But the problem is I cannot get
document.getEle mentById work, because the list item id generated by ASP.net
is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList" . While
document.getEle mentById is supposed to identify element BY NAME but not by ID
attribute.

Anyone has luck with this problem?

strout
Nov 18 '05 #1
4 4453
You need to use the .ClientID property not .ID property.

Greg

"strout" <st****@discuss ions.microsoft. com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
I want to do some client-side operation by click different radiobuttonlist .

I tried to add "onclick" event for each itemlist, by register startup
clientside javascript. But the problem is I cannot get
document.getEle mentById work, because the list item id generated by
ASP.net
is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList" . While
document.getEle mentById is supposed to identify element BY NAME but not by
ID
attribute.

Anyone has luck with this problem?

strout

Nov 18 '05 #2
This ID is in HTML attribute. client side.

"Greg Burns" wrote:
You need to use the .ClientID property not .ID property.

Greg

"strout" <st****@discuss ions.microsoft. com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
I want to do some client-side operation by click different radiobuttonlist .

I tried to add "onclick" event for each itemlist, by register startup
clientside javascript. But the problem is I cannot get
document.getEle mentById work, because the list item id generated by
ASP.net
is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList" . While
document.getEle mentById is supposed to identify element BY NAME but not by
ID
attribute.

Anyone has luck with this problem?

strout


Nov 18 '05 #3
???

You lost me. Below is some code I use to set focus on a control using
javascript. You pass it the ClientID (which will be the HTML ID when
rendered).

Also, getElementById wants the HTML "ID". Not sure what you mean "BY
NAME"...

Make sure the quotes in the getElement ById function don't trip you up.

Good luck.
Greg

SetFocus(txtPas sword.ClientID)

Private Sub SetFocus(ByVal clientID As String)
Dim strjscript As String = "<script language=""java script"">"
strjscript &= "document.getEl ementById(""" & clientID &
""").focus( );"
strjscript &= "</script" & ">" 'Don't Ask, Tool Bug
Page.RegisterSt artupScript("MY setfocus", strjscript)
End Sub
"strout" <st****@discuss ions.microsoft. com> wrote in message
news:BD******** *************** ***********@mic rosoft.com...
This ID is in HTML attribute. client side.

"Greg Burns" wrote:
You need to use the .ClientID property not .ID property.

Greg

"strout" <st****@discuss ions.microsoft. com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
>I want to do some client-side operation by click different
>radiobuttonlis t.
>
> I tried to add "onclick" event for each itemlist, by register startup
> clientside javascript. But the problem is I cannot get
> document.getEle mentById work, because the list item id generated by
> ASP.net
> is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList" .
> While
> document.getEle mentById is supposed to identify element BY NAME but not
> by
> ID
> attribute.
>
> Anyone has luck with this problem?
>
> strout


Nov 18 '05 #4
Ok, I see what what you mean about the NAME attribute. But I am pretty
certain that getElementById does just what it says. Get the element by ID
attribute, not NAME attribute.

I've had no problem using it in a datagrid what my ID renders as
"ucSheet_grid__ ctl5_lblItem" and so forth. In fact a textbox in my datagrid
renders as a span without even a NAME attribute.

Greg
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
???

You lost me. Below is some code I use to set focus on a control using
javascript. You pass it the ClientID (which will be the HTML ID when
rendered).

Also, getElementById wants the HTML "ID". Not sure what you mean "BY
NAME"...

Make sure the quotes in the getElement ById function don't trip you up.

Good luck.
Greg

SetFocus(txtPas sword.ClientID)

Private Sub SetFocus(ByVal clientID As String)
Dim strjscript As String = "<script language=""java script"">"
strjscript &= "document.getEl ementById(""" & clientID &
""").focus( );"
strjscript &= "</script" & ">" 'Don't Ask, Tool Bug
Page.RegisterSt artupScript("MY setfocus", strjscript)
End Sub
"strout" <st****@discuss ions.microsoft. com> wrote in message
news:BD******** *************** ***********@mic rosoft.com...
This ID is in HTML attribute. client side.

"Greg Burns" wrote:
You need to use the .ClientID property not .ID property.

Greg

"strout" <st****@discuss ions.microsoft. com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
>I want to do some client-side operation by click different
>radiobuttonlis t.
>
> I tried to add "onclick" event for each itemlist, by register startup
> clientside javascript. But the problem is I cannot get
> document.getEle mentById work, because the list item id generated by
> ASP.net
> is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList" .
> While
> document.getEle mentById is supposed to identify element BY NAME but
> not by
> ID
> attribute.
>
> Anyone has luck with this problem?
>
> strout


Nov 18 '05 #5

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

Similar topics

3
9011
by: William LaMartin | last post by:
If I create a RadioButtonList with, say, two items, then after the page loads and I select one of the items and then click on a button whose click event contains some code to display the RadioButtonlList's selected value, there is nothing. On a postback, with the dynamically created button list visible on the page and the first item selected, if I try some code like "If Me.RadioButtonList1.Items(0).Selected = True Then.......", then I...
1
1527
by: V. Jenks | last post by:
I have a RadioButtonList and an ImageButton in my form. In the ImageButton Click event handler I'm trying to redirect to a new page, passing the value from the RadioButtonList in a querystring. Why do I get a null reference when trying to get the value of the RadioButtonList? some code:
3
1419
by: Mark Broadbent | last post by:
try as I might (and using different properties) this control always seems to be returning the first element of the control as the "selected" item even though I am selecting the second element. All I need it the index number to reference a particular row num of a dataset. I only just noticed this today but it if I cant determine the selected radiobuttonlist item then it reders this control useless. Hope someone can help? --
5
3372
by: Mike Salter | last post by:
I created a page that reads a DB for questions and possible answers (usuallyYes/No). I create a panel for each group of questions, and add a panel for each question to the Group panel. To the Question panel I add a label with the question text, and a radiobuttonlist with the answers. I have an eventhandler I add to each radiobuttonlist, which is the same for all. The Group panels are then added to Placeholder1.Controls. I then add...
4
4009
by: juststarter | last post by:
Hello, I have an aspx file where i've put a placeholder element. On load (page_load) i create dynamically an html table which contains a checkbox and a radiobuttonlist in each tablerow . The radiobuttonlist contains two items (yes,no). Both the checkboxes and the radiobuttonlist are NOT autopostbacked ( .autopostback = false). When i press the submit button a sub (submit_pressed) is run. My problem is that i can not get the selected items...
5
2692
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hallo, I have a radiobuttonlist control that is added on a custom Web User Control. This control has a property that exposes the SelectedIndex property of the embedded radiobuttonlist. When running this in IE, behaviour is as I would expect it. If I select an item and do a postback, the page remembers my selection when reloading, and the SelectedIndex property of my control returns the correct value.
6
2644
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered in the page and I've got code to get the selected value from it in the Radiobuttonlist_SelectedIndexChanged event. The code in there is: Protected Sub rblFMSValue_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
2
2817
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the button again (or at least detect that an authorisation is already in progress and do nothing) while the first authorisation is in progress. Can someone help me out? I've tried the following but none of the solutions work: 1) Disabling the...
1
10765
by: renuami | last post by:
Hello friends please advise....... I am building an application for Survey. For this i have GridView with two Template fields. The first Template has Label (To display question text) and RadioButtonList (for options). The 2nd Template field is the primary key value. And i have a button on the form. In the button click event i wrote code to grab RadioButtonList values.But the selected value is coming as null....PLEASE ADVISE.... Let me...
0
9535
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
10467
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
10244
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...
0
10021
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...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5454
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.