How to Enable or Disable CheckBox Programmatically 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.Click ToolBox-> Double Click on CheckBox(or drag and drop CheckBox on Design view)->change CheckBox Text Property to "CheckBox to Check"

ToolBox->Double Click on Label->Right click on label->select Properties->make text property empty(erase label Text properties text and do not write anything)

ToolBox->Double click on Button->Right click on Button->select Properties->change Text property to Enable
Add another Button and name it Disable
asp.net CheckBox Control
Your Design window should look like this
























3.Double Click on Enable Button to get the code behind and write this code
4..Double Click on Disable Button and write this code
5.Click F5 to run your project->ok
asp.net CheckBox control
After Running your project
asp.net CheckBox control Enable
After clicking Enable Button
CheckBox control Disable
After clicking Disable Button

No comments:

Post a Comment