Click here to Skip to main content
12,300,841 members (68,847 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET ASP.NET4
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
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
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 30-Nov-12 20:49pm
dilzz1.3K
Edited 30-Nov-12 21:32pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Go this way :
My_Menu.BAL.BusinessAccessLayer_Class BALObj = new My_Menu.BAL.BusinessAccessLayer_Class();
  Permalink  
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
Krunal R 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
Krunal R 1-Dec-12 3:07am
   
Send your project me: kunalrohit92@gmail.com
dilzz 1-Dec-12 3:11am
   
ok..sure.. just wait please...
dilzz 1-Dec-12 3:20am
   
i have sent my project.. please have a look....
Krunal R 1-Dec-12 4:41am
   
Your problem has been solved, I have already sent the mail to you.. Please have a look at that :) :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.

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();
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 1 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100