Suppose there is CheckBox and I want to perform checkBox_CheckedChanged event when it is checked.how to do that?
What is the resion to make autoPostBack=true;Ya its working now but why its not working when autopostback =false;
Shalni
2010-09-23 06:17:07
A:
Markup:
<asp:CheckBox runat="server" AutoPostBack="true" OnCheckedChanged="checkBox_CheckedChanged" />
Code-behind:
using System.Web.UI.WebControls;
protected void checkBox_CheckedChanged(object sender, EventArgs e)
{
CheckBox checkBox = (CheckBox)sender;
bool @checked = checkBox.Checked;
// do other stuff
}
abatishchev
2010-09-22 06:23:02
sir,If i write bool @checked = checkBox.Checked; then error comes that checked is keyword identifier expected. This error come? So That code is not working
Shalni
2010-09-22 07:57:56
@Shalni: I guess that `bool checked` doesn't work because of syntax keyword but `bool @checked` where escaping took place - should work properly. Does it?
abatishchev
2010-09-22 08:27:17
bool @checked is fine but checkBox.Checked is giving error.But I remove that error by using if condition.
Shalni
2010-09-22 08:42:54