Why when a control does contain value but it’s set to .Enable=False that all controls become disable (that’s ok) but why that the ViewState doesn’t retain the data on the next post back? If I get the UserControl without modifing its Enable state, the ViewState work between post back.
How can we disable a UserControl that all its control become disable (this part work) but all of them KEEP use the ViewState (this doesn’t work)?
Clarification:
1)In the aspx.cs click button EDIT:
myControl.Enabled = false;
//This produce to have all controls in myControl to be disabled.
2)In the asp.cs: click Save to leave the EDIT state:
myControl.Enabled = true;
//This produce that all controls inside myControl are blank : no viewstate!
Other postback works because we do not put myControl.Enable to false.
Specifying
.Enable=Falseis like a server-side disable, NOT a client-side disable. This is for security purposes so you can truly disable an input element even if the user uses some client-side trickery to “re-enable” it. If you want to perform a client-side disabling, you’ll need to use script for that, or perhaps use areadonlyattribute.