Object across pages

G

Guest

I have a web applicatin with 2 web forms.Form 1 contains 2 textboxes -
txtName, txtAge and Submit button. Form 2 Contains 2 textboxes - txtsubject,
txtSection and submit button. I have a class Student as follows

Public Class Student
dim name as string
dim age as string
dim subject as string
dim section as string
End Class

I am storing the data entered by user in form 1 in name and age members of
the instantiated class. Then I save the class as session variable. In form 2
I am reffering to same class stored in session variable to access name and
age of student. Then I am trying to store the values of subject and section
in the same class. But i get error message.

I have Following queries regarding same.

1) How do I declare or instantiate my class so that it can be accessed
anywhere in the application and where should i instantiate it? The class
shall be instantiated as session for a user starts and should end when it
ends.

2) I want that data added to class in form 1 shall be available in form 2
and at the same time it shall be possible for me 2 add more data to same
stored class in form 2. How to do this?

Please Help...
 
K

Kevin Spencer

Hi Saket,

The anwer to both questions is the same. If you store it in Session, it will
be persistent throughout the Session, destroyed automatically when the
Session ends, and available to all pages visited by that client during that
Session.

If you could share the exact error message we could help you diagnose the
problem you're having. But you are on the right track using Session.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top