R
Ryan Taylor
Hello.
I am having another issue. I need to execute some JavaScript whenever a
radio button is clicked. I am currently using a RadioButtonList control to
generate the radio buttons because of its excellent ability to be bound to a
datasource. No matter what I do though, I am not able to add an onclick
event to the individual radio buttons in the page. How might I go about
this? Currently I have
private void Questions_OnItemDataBound(object sender, RepeaterItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
RadioButtonList rbl = (RadioButtonList)
e.Item.FindControl("AnswerOptions");
rbl.DataTextField="fullOptionDescription";
rbl.DataValueField="answerOptionId";
rbl.DataSource = ((DataRowView)
e.Item.DataItem).CreateChildView("questionId");
rbl.DataBind();
foreach(ListItem li in rbl.Items)
li.Attributes.Add("OnClick", "needToConfirm = true;");
}
}
I've tried other variants as well with no success.
Thanks in advance.
Ryan Taylor
I am having another issue. I need to execute some JavaScript whenever a
radio button is clicked. I am currently using a RadioButtonList control to
generate the radio buttons because of its excellent ability to be bound to a
datasource. No matter what I do though, I am not able to add an onclick
event to the individual radio buttons in the page. How might I go about
this? Currently I have
private void Questions_OnItemDataBound(object sender, RepeaterItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
RadioButtonList rbl = (RadioButtonList)
e.Item.FindControl("AnswerOptions");
rbl.DataTextField="fullOptionDescription";
rbl.DataValueField="answerOptionId";
rbl.DataSource = ((DataRowView)
e.Item.DataItem).CreateChildView("questionId");
rbl.DataBind();
foreach(ListItem li in rbl.Items)
li.Attributes.Add("OnClick", "needToConfirm = true;");
}
}
I've tried other variants as well with no success.
Thanks in advance.
Ryan Taylor