Export (0) Print
Expand All

Control.Page Property

Gets a reference to the Page instance that contains the server control.

[Visual Basic]
Public Overridable Property Page As Page
[C#]
public virtual Page Page {get; set;}
[C++]
public: __property virtual Page* get_Page();
public: __property virtual void set_Page(Page*);
[JScript]
public function get Page() : Page;
public function set Page(Page);

Property Value

The Page instance that contains the server control.

Remarks

This property's value reflects the name of the .aspx file that contains the server control.

Example

[Visual Basic, C#, C++] The following example overrides the Control.Render method. 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.

[Visual Basic] 
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 occured")
   End If
End Sub 

[C#] 
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 occured");
 }

[C++] 
protected:
   void Render(HtmlTextWriter* output)
   {
      output->Write(S"Welcome to Control Development!<br>");

      // Test if the page is loaded for the first time
      if (!Page->IsPostBack)
         output->Write(S"Page has just been loaded");
      else
         output->Write(S"Postback has occured");
   }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Web.UI Namespace | Page

Show:
© 2014 Microsoft