using check box event to enable a button

private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
            {
                  if(CheckBox1.Checked)Button1.Enabled=true;
            }

AUTOPOST BACK IS TRUE.

I want to enable Button1 as soon as check box is checked
however no luck !

I am using C# in asp.net
LVL 2
deersuperAsked:
Who is Participating?
 
ayha1999Commented:
Hi,

First disable button1 in pageload event, make checkbox's autopostback=true.

private void Page_Load(object sender, EventArgs e)
{
 if (!(Page.IsPostBack)) {
   Button1.Enabled = false;
 }
}

private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
 if (CheckBox1.Checked == true) {
   Button1.Enabled = true;
 } else {
   Button1.Enabled = false;
 }
}

hope this helps.

ayha
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.