页面类派生自TemplateControl类;
public class Page : TemplateControl, IHttpHandler
类TemplateControl派生自抽象Control类;
public abstract class TemplateControl : Control, ...
在Control类Page派生的类中,有一个名为 Page 的虚拟属性;
// Summary:
// Gets a reference to the System.Web.UI.Page instance that contains the server
// control.
//
public virtual Page Page { get; set; }
在Page类中有诸如IsPostBack等属性IsValid;
// Summary:
// Gets a value that indicates whether the page is being rendered for the first
// time or is being loaded in response to a postback.
//
public bool IsPostBack { get; }
因此,
由于aspx页面是从Page类派生的,所以它也继承TemplateControl和Control类。在Control类中有一个名为 as 的公共属性,Page因此您可以访问Page类中的属性。并且Page类具有诸如等之类的公共属性IsPostback,IsValid因此您可以从属性中使用这些属性Page。
public class Test : Page
{
public Test()
{
bool test = this.IsCallback;
}
}