Page.RegisterViewStateHandler Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Causes page view state to be persisted, if called.

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

Public Sub 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.

System_CAPS_noteNote

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

' Create a custom HtmlForm server control named MyForm.
Public Class MyForm
   Inherits HtmlForm

   ' MyForm inherits all the base funcitionality
   ' of the HtmlForm control.
   Public Sub New()
   End Sub 'NewNew

   ' Override the OnInit method that MyForm inherited from HtmlForm.
   <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
   Protected Overrides Sub OnInit(e As EventArgs)
      ' Save the view state if there are server controls on
      ' a page that calls MyForm.
      Page.RegisterViewStateHandler()
   End Sub 'OnInit
End Class 'MyForm

.NET Framework
Available since 1.1
Return to top
Show: