Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)
    {

    }
}

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)
    {
        
    }
}


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
Posted
Updated 1-Dec-11 15:22pm
v5
Comments
RaviRanjanKr 1-Dec-11 13:59pm    
[Edited]code is wrapped in Pre tag[/Edited]

1 solution

GlobalVariable (which sucks as a name, btw) has to inherit from System.Web.UI.Page
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-Dec-11 14:08pm    
My 5.
As to the names: why I often see applications having the work "Application" in its name, "Class" in class, "Event" in event, etc? Isn't that silly?
GlobalVariable is silly squared, of course, because this a class. However, "class System.Object" already gives an example of bad naming.
--SA
Wonde Tadesse 1-Dec-11 14:12pm    
5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900