Yes, I verified that if the Master Page doesn't EnableViewState, no viewstate is saved. I traced through the framework code, it calls SaveViewStateRecursive and SaveAllState. Since the Master is the top level page (but not the parent), it won't save anything.
Therefore It's probably best to always enable Viewstate in the master, and if you don't need viewstate in a page or control, explicitly disable it.
I must say this was very frustrating for me as well. Strange that controls enableviewstate=true by default, but a page's default enableViewState=false. For me to finally discover that fact took me several hours of tracing through the Framework code.
For most controls (checkboxes, text boxes) to properly fire the OnChanged event, you must enable ViewState at the page and Master Level.
I hope this helps someone else out there save the time I spent.
I don't know guys whether u get your problem solved or not .... but i also face this problem and almost pulled my all hair for 2 days
but now i m able to solve this issue, so just to help any other person who comes here,while searching regarding this problem.....
Check box Problem:
This is a known problem with ASP.NET - for some reason ASP.NET won't update a checkbox on postback if it was disabled during page load and not checked for postback. I don't know exactly why that is though - if you make the checkbox unselected by default
and select it, the value is changed on the server correctly.
The workaround is to add a hidden field to the page that represents the state of the checkbox, then update the field's value to "ON" or "OFF" for example, whenever the checkbox is clicked.
Then on the server you check the value of the hidden field, not the checkbox itself, as the hidden field is always posted.
Ganesh@Nilgr...
Contributor
6074 Points
2354 Posts
Re: Checkbox not firing when unchecking using OnCheckedChanged
Aug 28, 2008 02:03 PM|LINK
Great[<:o)]
Please Mark As Answer If my reply helped you.
d_wade
Member
2 Points
4 Posts
Re: Checkbox not firing when unchecking using OnCheckedChanged
Feb 17, 2010 07:04 PM|LINK
Yes, I verified that if the Master Page doesn't EnableViewState, no viewstate is saved. I traced through the framework code, it calls SaveViewStateRecursive and SaveAllState. Since the Master is the top level page (but not the parent), it won't save anything. Therefore It's probably best to always enable Viewstate in the master, and if you don't need viewstate in a page or control, explicitly disable it.
I must say this was very frustrating for me as well. Strange that controls enableviewstate=true by default, but a page's default enableViewState=false. For me to finally discover that fact took me several hours of tracing through the Framework code.
For most controls (checkboxes, text boxes) to properly fire the OnChanged event, you must enable ViewState at the page and Master Level.
I hope this helps someone else out there save the time I spent.
Lord Razor
Member
2 Points
1 Post
Re: Checkbox not firing when unchecking using OnCheckedChanged
Jan 31, 2011 12:20 PM|LINK
I also had this problem and what helped me was to set the view state enabled on the checkbox control it self
sam.kumar
Member
62 Points
46 Posts
Re: Checkbox not firing when unchecking using OnCheckedChanged
Apr 09, 2012 11:02 AM|LINK
I don't know guys whether u get your problem solved or not .... but i also face this problem and almost pulled my all hair for 2 days
but now i m able to solve this issue, so just to help any other person who comes here,while searching regarding this problem.....
Check box Problem:
This is a known problem with ASP.NET - for some reason ASP.NET won't update a checkbox on postback if it was disabled during page load and not checked for postback. I don't know exactly why that is though - if you make the checkbox unselected by default and select it, the value is changed on the server correctly.
The workaround is to add a hidden field to the page that represents the state of the checkbox, then update the field's value to "ON" or "OFF" for example, whenever the checkbox is clicked.
Then on the server you check the value of the hidden field, not the checkbox itself, as the hidden field is always posted.