|
-
Dec 10th, 2002, 05:58 AM
#1
Thread Starter
Lively Member
Variable lifetimes in aspx forms
Hi,
I've got a form and I want to maintain some variables that are received from a query string, i.e.,
In the public Class of the aspx.vb file of my aspx webform, I want to create a variable that has a lifetime of the form itself.
Can that be done "in code" or do I need to write it to a hidden field on the form as you would in ASP ?
thanks
Andy
-
Dec 10th, 2002, 09:19 AM
#2
There is no such thing as 'lifetime of a form' in ASP .NET. When someone goes to your page, the asp .net engine creates HTML and sends it to their browser. If you want to save variables you can use the Session, Application, and cache objects.
-
Dec 10th, 2002, 09:23 AM
#3
Thread Starter
Lively Member
I just wondered if there was some other ASP.NETty way that it stored variables other than how you would pass them around in ASP. As I hadn't found one, I assumed not and you've confirmed it.
cheers
Andy
-
Dec 10th, 2002, 09:44 AM
#4
You still have the same basic fundimental problem with ASP .NET as with ASP and that is stateless pages. You just do it the same way as you would have before using Session variables, querystrings, hidden forms values, etc.
-
Dec 10th, 2002, 10:01 AM
#5
Thread Starter
Lively Member
that's fine, I just wondered that seeing as how .NET seems to do so much more stuff, whether it had some cunning way of preserving form data other than actually on the form. I guess (as you say) , the Cache object, or session object can be used (as with normal ASP).
cheers
Andy
-
Dec 10th, 2002, 12:47 PM
#6
If you want to have variables keeping the values on a particular page, then you can also use ViewState object.
-
Dec 10th, 2002, 01:23 PM
#7
What about using a Module wont that work? Or is that bad form?
-
Dec 11th, 2002, 09:08 AM
#8
Addicted Member
Originally posted by Edneeis
What about using a Module wont that work? Or is that bad form?
I'm not positive you can use modules in ASP.NET, but I could be wrong. You could store in the Global.asax file, which from my understanding kind of works like a module.
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
|