Handle RadioButtonList click event by Clientscript

G

Guest

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
 
G

Greg Burns

???

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
 
G

Greg Burns

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
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top