Each web form control hasViewstateAttribute (fromControlThis attribute enables the web form control to participate inViewstateManagement.ViewstateIsSytem. Web. UI. statebag, Which is equivalent to the data structure of the hash table. Controls can save data as key/value pairs inViewstate.ViewstateUse the ASP. NET page framework to maintain the variable as a string and hide the variable form to make a round-trip with the client. When sending a response, the page framework analyzes input strings from hidden variables and fills in the control hierarchy of the page withViewstateAttribute. UseViewstateProperty, the control can restore its status (set the attributes and fields to their values before sending back ).
Public bool signed
{
Get
{
If (viewstate ["Signed"] = NULL)
Viewstate ["Signed"] = false;
Return (bool) viewstate ["Signed"];
}
Set
{
Viewstate ["Signed"] = value;
}
}
the Code section marked in red sets the default value for viewstate, otherwise, the property of the control will display "the object is not set to the referenced instance" in the Property Window of the designer ". This issue does not exist for string type attributes.