Hi there,
I am trying to add a client side JavaScript onclick handler to radio
buttons in a list. Here is part of my code:
Dim rdYesNo As System.Web.UI.WebControls.RadioButtonList
' Get ref. to RadioButtonList
rdYesNo = e.Item.FindControl("pnlYesNo").FindControl("rdYesNo")
' Change label for Yes button
rdYesNo.Items(0).Text = "YesYesYes"
' Change label for No button
rdYesNo.Items(1).Text = "NoNoNo"
' Add JavaScript handler
rdYesNo.Items(0).Attributes("onclick") = "return switchValidation(true);"
rdYesNo.Items(1).Attributes("onclick") = "return switchValidation(false);"
The code above runs fine; no errors are generated. However, the client side
onclick is not added to each button. The references to the RadioButtonList
and its Items collection seem fine as I am able to change the labels of the
buttons.
Anybody any ideas why .Attributes does not work?
Imar