Click to See Complete Forum and Search --> : call button event explicitly
sansircar
January 24th, 2006, 09:45 PM
I wanted to call the click event of the button on the click of a checkbox -
for eg:-
i wanted to call the event below explicitly when a checkbox is checked
private void btnSave_Click(object sender, System.EventArgs e)
{
}
please suggest
Alsvha
January 25th, 2006, 02:30 AM
Place the code you normally have in your button click event into a sub and then have all relevant events call that sub.
ITGURU
January 25th, 2006, 02:41 AM
Dear sansircar,
To set a click event (btnSave_Click) with your check box, please follow following steps:
1. Open your web form in Design Mode.
2. Right click on your check box and select Properties in the context menu.
3. Set AutoPostBack Property in Property window as True.
4. In Properties window click on Event toolbar button which u can find it 4 place in Properties window toolbar and it look like as lightening.
5. Specify btnSave_Click in CheckedChanged Event.
Now you can get your event btnSave_Click fired when user change the check state of the Check box.
mmetzger
January 25th, 2006, 10:06 AM
Alsvha's right on this one. The problem with specifically adding the option to an event handler in this case is that the method header may not match what gets called. If you move the actual code in the btnSave_Click method to a different sub, you can then call it from multiple methods even if the header is not the same.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.