页面类派生于TemplateControl
class;
public class Page : TemplateControl, IHttpHandler
and TemplateControl
类派生自抽象Control
class;
public abstract class TemplateControl : Control, ...
In 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; }
In the Page
类有类似的属性IsPostBack
, IsValid
etc;
// 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; }
Thus,
由于aspx页面源自Page
类,它也继承TemplateControl
and Control
类。在Control
类有一个名为的公共属性Page
这样你就可以访问Page
你班级的财产。和Page
类具有公共属性,例如IsPostback
and IsValid
等等,所以你可以使用这些属性Page
财产。
public class Test : Page
{
public Test()
{
bool test = this.IsCallback;
}
}