Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RadioButton CheckChanged event not firing on first selection

0 views
Skip to first unread message

Emma Middlebrook

unread,
Apr 23, 2008, 10:05:44 AM4/23/08
to
Hi there,

I'm having problems in an ASP.NET page that is dynamically creating
and displaying radio buttons. I have setup a checkchanged event and
specified AutoPostBack to true.

When the page loads none of the radio buttons are checked by default.
When the user checks the first one, the page refreshes but the
checkchanged event never triggers. If you then select a different
radio button, the postback occurs but the event also triggers.

Can anyone suggest something that might be stopping the first event to
be sent?

The display code creating the controls is:

void DisplayQuestion(Question question, bool checkRadio)
{
Label lblTitle = new Label();
lblTitle.ID = "lblQuestionOneTitle" + uniqueId;
lblTitle.Text = string.Format("{0}.{1}. ", questionSequence,
questionSecondSequence);

Label lblQuestionText = new Label();
lblQuestionText.ID = "lblQuestionText" + uniqueId;
lblQuestionText.Text = question.QuestionText;

RadioButton rbNo = new RadioButton();
rbNo.Checked = checkRadio;
rbNo.ID = "rbNo" + uniqueId;
rbNo.GroupName = "QuestionAnswer" + uniqueId;
rbNo.Text = "No";
rbNo.CheckedChanged += QuestionNoAnswered;
rbNo.AutoPostBack = true;

RadioButton rbYes = new RadioButton();
rbYes.Checked = false;
rbYes.ID = "rbYes" + uniqueId;
rbYes.GroupName = "QuestionAnswer" + uniqueId;
rbYes.Text = "Yes";
rbYes.CheckedChanged += QuestionAnswered;
rbYes.AutoPostBack = true;

RadioButtonList rbl = new RadioButtonList();
rbl.Controls.Add(rbNo);
rbl.Controls.Add(rbYes);

upQuestionBlock.ContentTemplateContainer.Controls.Add(lblTitle);

upQuestionBlock.ContentTemplateContainer.Controls.Add(lblQuestionText);
upQuestionBlock.ContentTemplateContainer.Controls.Add(rbl);
upQuestionBlock.ContentTemplateContainer.Controls.Add(rbYes);
upQuestionBlock.ContentTemplateContainer.Controls.Add(rbNo);
}

Thanks,

Emma

0 new messages