473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.getElementById work, because the list item id generated by ASP.net
is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList". While
document.getElementById is supposed to identify element BY NAME but not by ID
attribute.

Anyone has luck with this problem?

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

Greg

"strout" <st****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.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.getElementById work, because the list item id generated by
ASP.net
is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList". While
document.getElementById 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****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.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.getElementById work, because the list item id generated by
ASP.net
is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList". While
document.getElementById 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(txtPassword.ClientID)

Private Sub SetFocus(ByVal clientID As String)
Dim strjscript As String = "<script language=""javascript"">"
strjscript &= "document.getElementById(""" & clientID &
""").focus();"
strjscript &= "</script" & ">" 'Don't Ask, Tool Bug
Page.RegisterStartupScript("MYsetfocus", strjscript)
End Sub
"strout" <st****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.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****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.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.getElementById work, because the list item id generated by
> ASP.net
> is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList".
> While
> document.getElementById 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@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.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(txtPassword.ClientID)

Private Sub SetFocus(ByVal clientID As String)
Dim strjscript As String = "<script language=""javascript"">"
strjscript &= "document.getElementById(""" & clientID &
""").focus();"
strjscript &= "</script" & ">" 'Don't Ask, Tool Bug
Page.RegisterStartupScript("MYsetfocus", strjscript)
End Sub
"strout" <st****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.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****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.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.getElementById work, because the list item id generated by
> ASP.net
> is like myRdoList_0, myRdoList_1 ... and the names are "myRdoList".
> While
> document.getElementById 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
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...
1
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....
3
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...
5
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...
4
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...
5
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...
6
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...
2
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...
1
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.