Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a ASP.Net web Application using 3-tire architecture.

First i have add a new webform and it contains some codes (name space, class etc...)

Here is the below code...

Default.aspx.cs
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace My_Menu
{
    public partial class Default : System.Web.UI.Page
    {
           //Something like this
        BusinessAccessLayer_Class Bal = new BusinessAccessLayer_Class();       
           //******

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

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



    }
}


Next i create a new folder and put a name "App_Code".
In that folder again i create a folder named "BAL".

And in that BAL folder i have added a new class named "BussinessAcessLayer.cs".

And it also contains some codes....

Here is the below code..

BusinessAccessLayer_Class.cs
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace My_Menu.App_Code.BAL
{
    public class BusinessAccessLayer_Class
    {
    }
}


When i create a object of BusinessAccessLayer_Class in Default webform..but i failed to create it.... can anyone please help me to create a object of the BusinessAccessLayer_Class , so only i can inherit the functions from the BusinessAccessLayer_Class .......


Thanks in advance..........

Dileep
Posted
Updated 30-Nov-12 21:32pm
v2

Go this way :
C#
My_Menu.BAL.BusinessAccessLayer_Class BALObj = new My_Menu.BAL.BusinessAccessLayer_Class();
 
Share this answer
 
v2
Comments
dilzz 1-Dec-12 2:58am    
When i used this above code . i am getting an error....

"The type or namespace name 'App_Code' does not exist in the namespace 'My_Menu' (are you missing an assembly reference?)".

Thanks ,

Dileep
[no name] 1-Dec-12 3:01am    
I have updated the solution..
dilzz 1-Dec-12 3:04am    
still showing the error.. :(

"The type or namespace name 'BAL' does not exist in the namespace 'My_Menu' (are you missing an assembly reference?)"

thanks,

Dileep
[no name] 1-Dec-12 3:07am    
Send your project me: kunalrohit92@gmail.com
dilzz 1-Dec-12 3:11am    
ok..sure.. just wait please...
In Visual Studio, Right click on class file and go to properties.

Check for BuildAction property of file. This should be set to "Compile"

then you can create instance as below

WebApplication1.App_Code.BAL.BusinessAccessLayer_Class d = new WebApplication1.App_Code.BAL.BusinessAccessLayer_Class();


if you set using directive like below you can create instance without full class name.

C#
using WebApplication1.App_Code.BAL;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BusinessAccessLayer_Class d = new BusinessAccessLayer_Class();
 
Share this answer
 
v2
Comments
dilzz 1-Dec-12 4:12am    
HO.. Thank you sir... thanks a lot.. its works fine....... :) am looking this code for past some days.... any way thanks a lot.... :)

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