Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Access Class Inside a Folder App_Code

Im new to c# and im creating a new web app. As usual i create a library of public functions used by the application in general.

Im using VS.net 2008, I created a project new projectwith the followin structure: root --App_Code globalClass.cs --scripts Default.aspx Default.aspx.cs

I need to import/using the globalClass inside App_Code/globalClass.cs Inside the code Behind of Default.aspx or any other.

This is the content of App_Code/globalClass.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;


namespace sgmedcs.globalClass
{
    public class claseGlobalX : System.Web.UI.Page
    {
        //HttpContext httpActual = HttpContext.Current;

        public string cargarSQL(string queryStr, string queryType)
        {
          //Scripting
        }
    }
}

I also used as namespace sgmed.App_Code.globalClass and sgmedcs.AppCode.globalClass

On the Default.aspx.cs i added using sgmedcs.globalClass; Or using sgmed.App_Code.globalClass; Or using sgmedcs.AppCode.globalClass

All of these approaches gives me "The type or namespace name 'claseGlobal' does not exist in the namespace 'sgmedcs' (are you missing an assembly reference?)"

What im missing, thanks for the help.

like image 786
Juan Garcia Avatar asked Dec 09 '22 12:12

Juan Garcia


1 Answers

Go into the properties of the class, and change the Build Action to Compile.

like image 159
James Johnson Avatar answered Dec 18 '22 09:12

James Johnson