如何继承System.Web.UI.Page中的App_Code类 [英] How to inherit App_Code class in System.Web.UI.Page

查看:77
本文介绍了如何继承System.Web.UI.Page中的App_Code类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个ASPX页面,其代码为lik

Hi,

I have one ASPX page and its code is lik

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public partial class _Default :System.Web.UI.Page 
{
    
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}


我在 App_Code 文件夹中还有另一个类文件,其代码为



I have another class file in App_Code folder and its code is


using System;
using System.Data.SqlClient;

/// <summary>
/// Summary description for GlobalVariable
/// </summary>
/// 

    public class GlobalVariable
    {
        public GlobalVariable()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public void test()
        {

        }       


    }


Now i want to inherit GlobalVariable class in _Default class . my code is like

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public partial class _Default :GlobalVariable 
{
    
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void LoadObject()
    {
        
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        
    }
}



但这是行不通的.我发现一些错误,例如.
确保此代码文件中定义的类与``inherits''属性匹配,并确保它扩展了正确的基类(例如Page或UserControl).

谁能帮我

在此先感谢

Rashed



But it is not working. I am finding some errors like.
Make sure that the class defined in this code file matches the ''inherits'' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Can any one help me

Thanks in advance

Rashed

推荐答案

GlobalVariable(糟透了名字,btw)必须从System.Web.UI.Page
GlobalVariable (which sucks as a name, btw) has to inherit from System.Web.UI.Page


这篇关于如何继承System.Web.UI.Page中的App_Code类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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