Condividi tramite


Page.RegisterViewStateHandler Metodo

Definizione

Causa la persistenza dello stato di visualizzazione, se chiamato.

public:
 void RegisterViewStateHandler();
public void RegisterViewStateHandler ();
member this.RegisterViewStateHandler : unit -> unit
Public Sub RegisterViewStateHandler ()

Esempio

// 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

Commenti

Il RegisterViewStateHandler metodo viene chiamato automaticamente tramite il HtmlForm controllo server. Se questo metodo non viene richiamato, lo stato di visualizzazione della pagina non verrà salvato in modo permanente.

Nota

In genere, solo il HtmlForm controllo server per la pagina chiama questo metodo.

Si applica a

Vedi anche