Export (0) Print
Expand All

Control.Page Property

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

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

[BindableAttribute(false)] 
public:
virtual property Page^ Page {
	Page^ get ();
	void set (Page^ value);
}
/** @property */
public Page get_Page ()

/** @property */
public void set_Page (Page value)

public function get Page () : Page

public function set Page (value : Page)

Not applicable.

Property Value

The Page instance that contains the server control.

Exception typeCondition

InvalidOperationException

The control is a Substitution control.

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

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.

No code example is currently available or this language may not be supported.
protected void Render(HtmlTextWriter output)
{
    output.Write("Welcome to Control Development!<br>");

    // Test if the page is loaded for the first time
    if (!(get_Page().get_IsPostBack())) {
        output.Write("Page has just been loaded");
    }
    else {
        output.Write("Postback has occured");
    }
} //Render 

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft