CheckedChanged Event not firing
-
Hi there, In ASP.Net, my checkbox is not firing its checkedchanged event when its the first postback of the page, and the checkbox was initially checked. If the checkbox was unchecked initially, it works everytime, but if it wasn't checked initially then it does not work the first time you uncheck it, then after you uncheck it and then when you check it again, it fires. It always posts back everytime, and __EVENTTARGET is always the checkbox's name. InitializeControls adds the event handler everytime, for both page_load and checkedchanged, even on the first postback when you uncheck the checkbox, it adds the handler but it does not get called. Page_Load always gets called. Anyone have any, off the top of their heads, ideas of what would cause it to ignore the checkedchanged event? Thanks for any suggestions of where I could start.
-
Hi there, In ASP.Net, my checkbox is not firing its checkedchanged event when its the first postback of the page, and the checkbox was initially checked. If the checkbox was unchecked initially, it works everytime, but if it wasn't checked initially then it does not work the first time you uncheck it, then after you uncheck it and then when you check it again, it fires. It always posts back everytime, and __EVENTTARGET is always the checkbox's name. InitializeControls adds the event handler everytime, for both page_load and checkedchanged, even on the first postback when you uncheck the checkbox, it adds the handler but it does not get called. Page_Load always gets called. Anyone have any, off the top of their heads, ideas of what would cause it to ignore the checkedchanged event? Thanks for any suggestions of where I could start.
I tried to see if I could reproduce your problem -- to no avail. I created the following code for an ASP.NET Web Form using VB.NET:
Private Sub Page\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here TextBox2.Text = "Page Loaded" End Sub Private Sub CheckBox1\_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged TextBox1.Text = "CheckBox1 Changed" End Sub
No matter what properties I set on CheckBox1, when I click the "submit" button on the page, if I have changed the value of CheckBox1, the value of TextBox1 changes. Perhaps you somehow broke the binding of the CheckChanged event to the CheckBox1_CheckChanged method?