Newbie question ( global variable definition page? )

Discussion in 'ASP .Net' started by Dan, Oct 29, 2003.

  1. Dan

    Dan Guest

    in my series of asp.net c# pages, I wish to create one
    page that will just contain various variables. Similar to
    the application.cfm page in coldfusion. how is this done?
     
    Dan, Oct 29, 2003
    #1
    1. Advertisements

  2. Dan

    e Guest

    From the Global.asax file, you can assign key/value items to the Application
    or Session (please excuse the VB, I'm unfamiliar with C# syntax)

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    'If you change this, you change it for everyone
    Application.Add("EveryonesPie", 3.14)
    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
    'If you change this, you change it for this particual user's session
    Session.Add("ThisUsersPie", 3.14)
    End Sub

    Then reference them wherever you need to:

    myPie = Session.Item("ThisUsersPie")
    theirPie = Application.Item("EveryonsPie")

    "Dan" <> wrote in message
    news:031701c39e4a$b8b5b330$...
    > in my series of asp.net c# pages, I wish to create one
    > page that will just contain various variables. Similar to
    > the application.cfm page in coldfusion. how is this done?
     
    e, Oct 29, 2003
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan Parkoff
    Replies:
    2
    Views:
    6,868
  2. Jean-Daniel Gamache

    global variable not assigned, newbie question

    Jean-Daniel Gamache, Nov 1, 2004, in forum: Python
    Replies:
    2
    Views:
    394
    Peter Hansen
    Nov 2, 2004
  3. Replies:
    1
    Views:
    502
    Michael Ekstrand
    Aug 21, 2005
  4. Bram Kuijper
    Replies:
    7
    Views:
    2,280
    James Kanze
    Jun 28, 2007
  5. jubelbrus
    Replies:
    5
    Views:
    807
    JohnQ
    Jul 20, 2007
  6. Pierre Yves
    Replies:
    2
    Views:
    715
    Pierre Yves
    Jan 10, 2008
  7. amit
    Replies:
    24
    Views:
    1,291
    Nobody
    Jan 18, 2010
  8. Sam Kong
    Replies:
    2
    Views:
    269
    Joel VanderWerf
    May 25, 2005
Loading...