RegisterViewStateHandler Method
Collapse the table of content
Expand the table of content

Page.RegisterViewStateHandler Method ()


Causes page view state to be persisted, if called.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public void RegisterViewStateHandler()

The RegisterViewStateHandler method is automatically called through the HtmlForm server control. If this method is not invoked, the page view state will not be persisted.


Typically, only the HtmlForm server control for the page calls this method.

Legacy Code Example

// Create a custom HtmlForm server control named MyForm. 
public class MyForm : HtmlForm
   // MyForm inherits all the base funcitionality
   // of the HtmlForm control.
   public MyForm():base()
   // Override the OnInit method that MyForm inherited from HtmlForm.

   [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
   protected override void OnInit( EventArgs e)
      // Save the view state if there are server controls on
      // a page that calls MyForm.

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft