Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing custom classes

Status
Not open for further replies.

mrsnrub

Programmer
Mar 6, 2002
147
AU
Hello,
I am still relatively inexperienced with ASP.NET and am trying to create some of my own classes using VB.NET and reference them in my ASP.NET pages.
So far I have created a simple 'Global.vb' file defining a class that I have called 'GlobalClass'. The initial code is as follows:

Imports System
Namespace GlobalNS

Public Class GlobalClass
Public Sub New()
End Sub

Public Function Login(u as String, p as String) as Boolean
return true
End Function
End Class
End Namespace

As you can see it doesn't do much yet! Note that at this stage I have called the Namespace 'GlobalNS'.

My question is how can I reference the functions and properties of this class from my ASP.NET page. So far I have tried creating a new instance of the class using:
Dim gc as New GlobalClass()
If (gc.Login) then...
But I get a compilation error saying that 'GlobalClass' is not defined.

Unfortunately, creating custom classes is 'out of the scope' of the new textbook I have just bought, and I haven't had much luck searching on the web. Could someone please explain what I am doing wrong and point me in the right direction so that I can get back on track!!

Thanks in advance

 
For those who are interested I have solved my problem. I simply needed these two lines at the top of my ASP.NET page to compile and include the VB.NET source:

<%@ Assembly src=&quot;Global.vb&quot; %>
<%@ Import namespace=&quot;GlobalNS&quot; %>

And I'm off and running again...
 
If you're using visual studio .net, you can also:

a) include the class file in your project. When you run your project, a dll is compiled which will include the class in it, allowing you to access the class

b) create a dll that houses the class, and reference it in your project's reference list.

Either way will work as well.

D'Arcy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top