How to call and use OnCheckedChanged Event in RadioButton in Asp.Net

1.File-> New-> Website->  ASP.NET Web Site(Visual C#) -> Ok

(Now You will see a Default.aspx page. To create your own page->click on dropdown list below Edit->click Add new item->Select Web Form->click Add)


 2.ToolBox-> Double Click on Label(or drag and drop Label on Design view)-> Right click on Label->Select Properties->change Text properties to  Select your Gender?

3. ToolBox-> Double Click on RadioButton->Right click on RadioButton->Select properties->Change text properties to Male->AutoPostBack properties to True->GroupName properties to RadioButtonControl
RadioButton Control Properties





















  ToolBox-> Double Click on RadioButton->Right click on RadioButton->Select properties->Change text properties to Female->AutoPostBack properties to True->GroupName properties to RadioButtonControl

4.ToolBox-> Double Click on Label-> Right click on Label->Select Properties->change Text properties to
 Blank(delete the label text so when you  run nothing will show)
 Your Design window should look like this
RadioButton Control Design window












5.Right click on Male RadioButton(RadioButton1)->properties->Click Events->Double click on CheckedChanged events(to get the code behind)











And write this code:

6..Right click on Female RadioButton(RadioButton2)->properties->Click Events->on CheckedChanged events DropDownList select RadioButton_CheckedChanged(it is the event name which we created on our first RadioButton's CheckedChanged Event)

7.Click F5 to run your project.
RadioButton Control  Output
After Running the project















When Male RadioButton Control Event
After clicking Male RadioButton












When Male RadioButton Control Event
After Clicking Female RadioButton

No comments:

Post a Comment