Global Variables on a VB.NET Web Page

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Fred Nelson (fred_at_smartybird.com)
Date: 02/26/04


Date: Thu, 26 Feb 2004 10:30:57 -0500

Hi:

I'm a relative newby so hopefully this is a simple question!

I have found that I can create global variables easily on a web page by
placing the dim statement before the first "private sub" in a program:

dim mydata as (whatever)

Public Sub Page_Load(etc..)

End Sub

This makes information that I place in this global variable available to
every click event on the page that I create just as it does in regular
VB.NET apps.

I'm curious to know if this is not a "best practice" - is info left in
memory if the user clicks away - or is this a "great practice". I haven't
seen any demos that use this so I'm curious if there is a down side

Thanks very much!

Fred



Relevant Pages

  • Re: Global Variables on a VB.NET Web Page
    ... The reason you haven't seen it because it's not a good practice. ... "Fred Nelson" wrote in message ... > placing the dim statement before the first "private sub" in a program: ... > Public Sub Page_Load ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Glolbal Variables Reset when using OleObjects
    ... Create OleObjects on a Worksheet (global variables are now dead) ... Make absolutely sure that you are running your init procedure immediately ... Public Sub init() ...
    (microsoft.public.excel.programming)
  • RE: returning hashes, and arrays
    ... > sub ParseLineForHomeAndVisitors() ... Two, I suspect 'Trail ... 3)Well, I've been taught not to use global variables, ... field goals attempted, field goals made, blocks ...
    (perl.beginners)
  • Re: Passing of variables
    ... doing so here suggests you may not appreciate the difference between a SUB ... Dim ObjSubFolderCollection ... you should use global variables as sparingly as possible. ... var2 = something ...
    (microsoft.public.scripting.vbscript)
  • Re: SCALAR(0x82dea94)
    ... > scipt only processes 20 lines at a time to avoid server time out. ... a scalar ref by accident, so it seems likely that the error is somewhere ... This is a good demonstration of the evil of global variables with ... And the sub is *much* too long. ...
    (comp.lang.perl.misc)