Page Class Object在哪里创建 [英] Where does Page Class Object gets created

查看:71
本文介绍了Page Class Object在哪里创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



有人能告诉我如何在不实例化Page Class对象的情况下使用Page类属性和方法吗?



例如 -

Hello,

Can anyone tell me how it is possible to use Page class properties and method without instantiating an Page Class object?

For Example -

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) //How do you use property of Page before you create "Page" class object
        {

        }

    }
}

推荐答案

您没有。

请记住,您的Login类派生自Page,所以页面包含的一切,你的cl ass包含。

Page类包含一个属性Page,它是在执行基类构造函数时为你预设的 - 这可能在你的类构造函数之前发生,你可能知道!
You don't have to.
Remember, your Login class is derived from Page, so everything Page contains, your class contains.
And the Page class contains a property "Page" which is preset for you when the base class constructor is executed - which happens before your class constructor, as you probably know!


这篇关于Page Class Object在哪里创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆