Tuesday, 22 January 2013 13:55

how to use RadioButton OnCheckedChanged event

Written by 
Rate this item
(0 votes)

Its easy to implement OnCheckedChanged event of RadioButton
control but most programmers makes mistake by not
including AutoPostBack="True" property in radiobutton
control.sometimes OnCheckedChanged not works for that
reason.here are the full working codes -

in page -

<asp:RadioButton ID="selectAddress1" runat="server" AutoPostBack="True"
Checked="true" OnCheckedChanged="checking_validation_first" /></b>

<b><asp:RadioButton ID="selectAddress2" AutoPostBack="True"
runat="server" OnCheckedChanged="checking_validation_second" /></b>

on code behind page -

protected void checking_validation_first(object source, EventArgs e)
{
if (selectAddress2.Checked == true)
{ selectAddress2.Checked = false; }
}
protected void checking_validation_second(object source, EventArgs e)
{
if (selectAddress1.Checked == true)
{ selectAddress1.Checked = false; }
}

Read 6368 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.