Page.RegisterViewStateHandler Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Powoduje, że stan widoku strony jest utrwalany, jeśli jest wywoływany.
public:
void RegisterViewStateHandler();
public void RegisterViewStateHandler ();
member this.RegisterViewStateHandler : unit -> unit
Public Sub RegisterViewStateHandler ()
Przykłady
// 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
Uwagi
Metoda jest wywoływana RegisterViewStateHandler automatycznie za pośrednictwem kontrolki HtmlForm serwera. Jeśli ta metoda nie zostanie wywołana, stan widoku strony nie zostanie utrwalone.
Uwaga
Zazwyczaj tylko kontrolka HtmlForm serwera dla strony wywołuje tę metodę.