Page.RegisterViewStateHandler Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Causes page view state to be persisted, if called.
public:
void RegisterViewStateHandler();
public void RegisterViewStateHandler ();
member this.RegisterViewStateHandler : unit -> unit
Public Sub RegisterViewStateHandler ()
Examples
// 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.
Page.RegisterViewStateHandler();
}
}
' 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
' 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
End Class
Remarks
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.
Note
Typically, only the HtmlForm server control for the page calls this method.
Applies to
See also
Colaborați cu noi pe GitHub
Sursa pentru acest conținut poate fi găsită pe GitHub, unde puteți, de asemenea, să creați și să consultați probleme și solicitări de tragere. Pentru mai multe informații, consultați ghidul nostru pentru colaboratori.