March 16th, 2011, 03:39 PM
Public Variables and Classes in ASP
I want to declare a variable that I can use in different parts of the application like we use variables in VB .NET
I would appreciate it very much if somebody could explain to me how to implement that.
Thank you very much and I appreciate your kindness.
March 28th, 2011, 07:21 AM
Re: Public Variables and Classes in ASP
Variables on a web page are very different to variables in a vb application..
I think the best way to describe it is.. Every time a web page is requested, the application starts up (with command line variables) processes the information, displays an output and ends.
of course the 'App' is running all the time, but it is often best to consider each page request this way. So trying to define global variables that you can keep data in between pages is not a viable option, as you'll have to monitor each individule user on the site and store global variables for each one..
Best bet is to look into using session cookies...
as these store your Global Variables on the Web browser itself and you can access it from any page on the site, and they are specific to each user...
Get a Cookie
UserId = Request.Cookies("Site")("UserID")
Set a Cookie
Response.Cookies("Site")("UserID") = UserId
Response.Cookies("Site").Expires = Date.Now.AddMonths(6)
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!