开发者

the checkbox event is not triggerd?

开发者 https://www.devze.com 2023-01-05 09:14 出处:网络
i have created checkbox event maually. chkCheckBox1.CheckedChanged += new EventHandler(chkCheckBox1_CheckedChanged);

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_CheckedChan开发者_开发问答ged(object sender, EventArgs e)
{
   ..........  
}

the checkbox event is not triggerd..


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.


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.


To trigger the following event

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

Set the checkbox autopostback property to TRUE

0

精彩评论

暂无评论...
验证码 换一张
取 消