views:

57

answers:

3

i have created checkbox event maually.

chkCheckBox1.CheckedChanged += new EventHandler(chkCheckBox1_CheckedChanged);

this event is not triggered,in pageload i have put

(!page.ispostback)
{
}

so when i clik the check box it goes to the page load and not going to the evnt

protected void chkCheckBox1_CheckedChanged(object sender, EventArgs e)
{
   ..........  
}

the checkbox event is not triggerd..

+4  A: 

Have you enabled AutoPostBack property on your control?

By default this is set to False when you add a checkbox control to your page. Try setting it to true.

Ben Cawley
Did this solve your problem? Let me know if you are still having problems.
Ben Cawley
A: 

Set the Autopostback property to true.

chkCheckBox1.CheckedChanged += new EventHandler(chkCheckBox1_CheckedChanged);

You have to wire up this event on every call to the page so if you have put this inside of the if(!Page.IsPostBack) then put it outside.

Take a look at this article Adding a dynamic control to a placeholder control and wire up the event. It shows an extra step for making things totally dynamic but the principles stay the same for what you're after.

Grz, Kris.

XIII
A: 

To trigger the following event

protected void chkCheckBox1_CheckedChanged(object sender, EventArgs e) { ..........
}

Set the checkbox autopostback property to TRUE

Chuckie