Newbie, Simple question about classes

BigMeat

New member
Joined
Jun 10, 2003
Messages
1
Hi

I am new to programming and I am trying to learn ASP.NET in VB.NET with VS .NET. My question is a simple one (I hope), basically I am trying to call a public sub class I have created in page2.aspx to Page1.aspx. However im not sure how to link to this other page and call a specific class. I want to use this approach as it will save me duplicating and repeating classes.

So I have built the following pages, the below code should call and show the data form the procedure FirstTest which is in the code behind page of Page2.aspx


Public Class Page1
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Put user code to initialize the page here
FirstTest()
End Sub

End Class


The page2.aspx code behind page is as follows:

Public Class Page2
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Put user code to initialize the page here
End Sub

Public Sub FirstTest()
Response.write(
 
Creae a new instance of your Page2 in your Page1.
Code:
Dim page2instance as new Page2()
Then use the variable to access subs or functions from there.
 
Back
Top