simple global variables and routines

simple global variables and routines

am 22.04.2008 23:36:24 von Web Search Store

Hello,

Is there a place I can put a class of global variables and have them
available in the page_load routine?

Here is a class:

Public Class globalvar

Public ddd As String = "howdy"

Public sub writeit

response.write ddd

end sub



End Class


In the page_load I would access them like this:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

ddd="goodbye"

writeit()
End Sub



This seems a hard thing to do in asp.net



I can put them all in a user control, and put an instance of it on each
page, if I have to.



Thanks for your help.



Scott

RE: simple global variables and routines

am 23.04.2008 02:43:00 von pbromberg

Declare the fields as public static (shared in VB.Net) fields in a static
class, or declare them in Global.Asax as public static (shared). Then you can
refer to these with Global.MyVariableName = myobject;
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net


"Web Search Store" wrote:

> Hello,
>
> Is there a place I can put a class of global variables and have them
> available in the page_load routine?
>
> Here is a class:
>
> Public Class globalvar
>
> Public ddd As String = "howdy"
>
> Public sub writeit
>
> response.write ddd
>
> end sub
>
>
>
> End Class
>
>
> In the page_load I would access them like this:
>
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
> Handles Me.Load
>
> ddd="goodbye"
>
> writeit()
> End Sub
>
>
>
> This seems a hard thing to do in asp.net
>
>
>
> I can put them all in a user control, and put an instance of it on each
> page, if I have to.
>
>
>
> Thanks for your help.
>
>
>
> Scott
>
>
>
>
>
>
>