Control.Page Control.Page Control.Page Control.Page Property

定义

获取对包含服务器控件的 Page 实例的引用。Gets a reference to the Page instance that contains the server control.

public:
 virtual property System::Web::UI::Page ^ Page { System::Web::UI::Page ^ get(); void set(System::Web::UI::Page ^ value); };
[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public virtual System.Web.UI.Page Page { get; set; }
member this.Page : System.Web.UI.Page with get, set
Public Overridable Property Page As Page

属性值

包含服务器控件的 Page 实例。The Page instance that contains the server control.

异常

示例

下面的示例将会重写 Control.Render 方法。The following example overrides the Control.Render method. 它使用Page属性Page.IsPostBack访问属性,并确定包含此控件的页是第一次加载还是为回发的结果。It uses the Page property to access the Page.IsPostBack property and determine whether the page that contains this control has just been loaded for the first time or is the result of a postback.

protected override void Render(HtmlTextWriter output) 
 {
   output.Write("Welcome to Control Development!<br>");

      // Test if the page is loaded for the first time
      if (!Page.IsPostBack)
          output.Write("Page has just been loaded");
     else
          output.Write("Postback has occurred");
 }
Protected Overrides Sub Render(output As HtmlTextWriter)
   output.Write("Welcome to Control Development!<br>")
   
   ' Test if the page is loaded for the first time
   If Not Page.IsPostBack Then
      output.Write("Page has just been loaded")
   Else
      output.Write("Postback has occurred")
   End If
End Sub 

注解

此属性的值反映包含服务器控件的 .aspx 文件的名称。This property's value reflects the name of the .aspx file that contains the server control.

适用于

另请参阅