Object access in multiple forms question again..

StephanyLin

New member
Joined
Aug 31, 2011
Messages
3
Programming Experience
Beginner
I am facing the problem as the one Robawtic was asking. I know theoretically it should be very simple and straightforward, but I just can't get my other page to access to the object created at Login page.

I've changed the form class from partial class to public class. Code are like below.

Public Class home
Inherits System.Web.UI.Page
Public iFirstTimeLoad As Boolean = True
Public Shared iCustomerAccount As New CustomerAccount.CustomerAccount()
End Class

Still no luck.

Can you tell me where I did wrong. I used to programming with VB, but VB .NET is so different from VB6. That is also the reason brought me to this forum.

Thanks.

Steph
 
Last edited:
lets say you have a class named GoHome and two forms you would declare it on a form as Public place As GoHome = New GoHome this way you can call it in another object.
 
Last edited:
I tried the syntax on my own class.. still can't access to that object. So I create another object -- iTextbox at form1, to isolate the possible problem in my class file

Public iTextbox As TextBox = New TextBox

I still can't access this iTextbox object at form2. Should I include some system files?

With my old class, I have the class file included under the bin folder.

also, the "form" I am refering to is aspx.


Thanks,
Steph
 
Last edited:
Unrelated platforms, thread split.
 
here is my test program...

the program look like this ..

Public Class home
Inherits System.Web.UI.Page
Public iCustomerAccount As CustomerAccount.CustomerAccount = New CustomerAccount.CustomerAccount

Protected Sub but_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles but_submit.Click
Dim ...
:
' Get account data from database...
:
' Assign data to iCustomerAccount Object, AccountName property....
iCustomerAccount.AccountName = iDataSet.Tables("CustLoginProfile").Rows(0)("cust_company").ToString()
Response.Redirect("userdefault.aspx")
End Sub
End Class

At userdefault.aspx ..........
Public Class userdefault
Inherits System.Web.UI.Page
public iLoginCustomerAccount as CustomerAccount.CustomerAccount = New CustomerAccount.CustomerAccount

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

... how do I access to iCustomerAcount object from here?


End Sub
End Class
 
Back
Top