Page.RegisterViewStateHandler 메서드

정의

이 메서드를 호출하면, 페이지 뷰 상태가 유지됩니다.

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

예제

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

설명

메서드 RegisterViewStateHandler 는 서버 컨트롤을 HtmlForm 통해 자동으로 호출됩니다. 이 메서드를 호출하지 않으면 페이지 보기 상태가 유지되지 않습니다.

참고

일반적으로 페이지의 서버 컨트롤만 HtmlForm 이 메서드를 호출합니다.

적용 대상

추가 정보