Adding Attributes to RadioButtonList Control

D

djarmoluk

I have a RadioButtonList (named rbAnswers) control within a repeater
control. When binding to the repeater, I am trying to add an "OnChange"
attribute to the individual list item controls (input controls of type
radio) using the following syntax:

For Each Item In rbAnswers.Items
Item.Attributes.Add("OnChange", MethodName)
Item.Enabled = False
Next

If I debug through the ItemDataBound event, "Item" is in fact a
ListItem control that represents a radio button within the rbAnswers
RadioButtonList control. However, the OnChange attribute I add is
placed in a <SPAN> tag before the <INPUT type=Radio> control thus
preventing my OnChange method from ever being called. Somehow, I need
to figure out how to get the OnChange attribute into the <INPUT>
control. Any ideas? What is strange about this is that the <INPUT>
control is disabled as desired (Item.Enabled = False).

To give some more background if it helps, I am creating an assessment
of about 40 questions generated from questions/answers in a database.
The assessment questions have dependencies such that the answer to one
question can disable/enable another question. I am creating the client
side javascript dynamically to do this. Changing an assessment response
should call the javascript which will then enable/disable a different
question.
 

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

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top