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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class Question

Status
Not open for further replies.

prprogrammer

Programmer
Jun 25, 2004
49
PR
Hi Want to know if the only way to use my class .vb in my .aspx pages is via namespaces. if exist other better way please tell me.
 
Can you provide an example of how you are using your class as your explanation isn't very clear?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Ok I have this class....
Public class Name

Function
End function

Sub
End Sub

Propert
end proper
.......

End class
the class is in myclass.vb file

I want to use the class in myfile.aspx...



 
How are you referencing it in your .aspx file? I believe it needs to be done via the @Page directive (at the top of the page). I believe it is the inherits method and then the name of the class, though I may be wrong. If this is the namespace you were referring to in your original post, then I believe it is the only way. (Am still new to this myself, so some of the syntax is as yet unfamiliar.)

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
You don't have to use the Page declarative or inherits method (you can use this if you want to use inheritance to extend the Page e.g. so you can have a menu automatically appear on each page).

To use a simple class you would just do something like:

Class:
Code:
Public Class Class1
    Public Function TestFunction()
        ' Do Nothing
    End Function
End Class

Page:
[/code]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyNewClass As New Class1
MyNewClass.TestFunction()
End Sub
[/code]

Hope this helps.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top