Using Class Library inside UserControl in ASP.Net C#

nagaraju60
 
on Jan 10, 2018 10:51 PM
3341 Views

Hi all,
I have a query. In my Solution i have Test.DL & Test.Web.UI.

Under Test.DL i have Ddlfile.cs in this file i have a class "Fruit"
under Test.Web.UI i have Fruits.ascx file.

Can i call fruit class from Test.DL to Fruits.ascx file? 
How should i achieve??
Please help me
Thanks in advance

Download FREE API for Word, Excel and PDF in ASP.Net: Download
kalpesh
 
on Jan 10, 2018 11:44 PM
on Jan 10, 2018 11:47 PM

In your one application Test.DL and Test.Web.UI Both are diffrent Project as Web user Interface and Data Access layer?
If Yes the just follow the below steps.

1) Right click on Project Name Test.Web.UI and select Add Reference Option.

2) Then Select Projects tab. where you need to select Project Name Test.DL and then click on Ok.

3) Reference of Project Test.DL is now Added now in Test.Web.UI project in References Folder.

4) You need to call the class from Test.DL file in Test.Web.UI so just Create object of class and use it If you have not Added name space which is same of class file in Test.DL then you need to add name space.

Or if Your Test.DL is in another application in another project then you need to add its reference like below.

1) Right click on Project Name Test.Web.UI and select Add Reference Option.

2) Then Select Browse tab. from where you can browse the Application name as Test.DL.

3) Go in Bin Folder And Select Test.DL Dll file and click on Ok.

4) Reference of Project Test.DL is now Added now in Test.Web.UI project in References Folder.

5) You need to call the class from Test.DL file in Test.Web.UI so just Create object of class and use it If you have not Added name space which is same of class file in Test.DL then you need to add name space.

In sample Example I just users Default.aspx page where i am accessing the class name same way you can call class in your UserControl.