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.

適用於

另請參閱