|
-
Mar 6th, 2006, 03:13 PM
#1
Thread Starter
Hyperactive Member
calling objects in asp.net [beginner's question]
Hi All, I have coded a class with the namespace quiz, it contains some methods like adding questions into database and validations.
Now i want to use it with asp.net, what do i need do in order to be able to call the class in code behind or in the asp.net page itself.
Another question is how do i pass an object (maybe a car object with mileage values, model etc) from 1 aspx page to another or keeping it in the session so i can retreive it whenever i need it.
Sorry, but i have tried to google and search the forum but couldnt get any answers. Maybe my phrasing for the search is bad. Thanks in advance.
cheers
-
Mar 6th, 2006, 03:19 PM
#2
Re: calling objects in asp.net [beginner's question]
Question 1)
You should just be able to add a reference to your ASP.Net project and use the object from there.
Question 2)
If you want to add objects to your session, I'm going to reffer you to the same question I had awhile back:
http://www.vbforums.com/showthread.php?t=377286
The example uses a dataset, but it would be easy to do the same thing with a structure.
Bah Bah Bah 
ViewState is for current page only. You would have to use session. Ignore that link! I suck...
Last edited by sevenhalo; Mar 6th, 2006 at 03:32 PM.
-
Mar 6th, 2006, 04:05 PM
#3
Thread Starter
Hyperactive Member
Re: calling objects in asp.net [beginner's question]
To sevenhalo, Thanks for the prompt reply. It helped.
You don't suck. We are all learning.
-
Mar 6th, 2006, 05:32 PM
#4
Re: calling objects in asp.net [beginner's question]
 Originally Posted by hyper88
Now i want to use it with asp.net, what do i need do in order to be able to call the class in code behind or in the asp.net page itself.
You have to instantiate it:
And then you use the newly created oQuiz object to access methods and properties.
EDIT: If that class is a stand alone DLL library, you have to reference it to the proyect, and THEN instantiate it.
 Originally Posted by hyper88
Another question is how do i pass an object (maybe a car object with mileage values, model etc) from 1 aspx page to another or keeping it in the session so i can retreive it whenever i need it.
If it's a complex object, like a array of strings, just use sessions.
You can do:
VB Code:
Dim myObject(5) as String
Session("myObject") = myObject
And to read it from anywhere:
VB Code:
Dim myObject() as string = Session("myObject")
To check if the Session("myObject") actually has a value, you can do this:
VB Code:
If Session("myObject") Is Nothing = False Then
'do something
End If
HTH
HoraShadow
Last edited by HoraShadow; Mar 6th, 2006 at 06:35 PM.
I do like the reward system. If you find that my post was useful, rate it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|