Global Variable declaration?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pieandpeas
    New Member
    • Sep 2007
    • 43

    #1

    Global Variable declaration?

    Is there a way of declaring a global variable in a masterpage that can be accessed from every aspx page the masterpage is linked to?
    Thanks
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can store the value of Request.Cookies ("Admin")("Supp lierID")
    in Session to make it global.

    e.g. Session("AdminS upplierId") = Request.Cookies ("Admin")("Supp lierID")



    Originally posted by pieandpeas
    Is there a way of declaring a global variable in a masterpage that can be accessed from every aspx page the masterpage is linked to?
    Thanks

    Comment

    • pieandpeas
      New Member
      • Sep 2007
      • 43

      #3
      Originally posted by shweta123
      Hi,

      You can store the value of Request.Cookies ("Admin")("Supp lierID")
      in Session to make it global.

      e.g. Session("AdminS upplierId") = Request.Cookies ("Admin")("Supp lierID")

      Yeah i would have used that, but the project unfortunately (for me) requires a global variable instead of a session, cookie etc..
      Just wondering if this is indeed possible.

      Thanks again

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        Originally posted by pieandpeas
        Yeah i would have used that, but the project unfortunately (for me) requires a global variable instead of a session, cookie etc..
        Just wondering if this is indeed possible.

        Thanks again
        Have you tried creating ab ase class for the master page to inherit from which contains a static variable of your intended "global" variable.

        I am not sure if this would work for web apps, but Sessions seem to be the best bet.

        cheers

        Comment

        • shweta123
          Recognized Expert Contributor
          • Nov 2006
          • 692

          #5
          Hi,

          You can also try viewstate , syntax is similar to sessions.

          Or declare a class and property inside it which will return the value you want.

          e.g.

          Public Class Globals
          Public ReadOnly Property getID() As int
          ...........
          End Property
          End class




          Originally posted by Shashi Sadasivan
          Have you tried creating ab ase class for the master page to inherit from which contains a static variable of your intended "global" variable.

          I am not sure if this would work for web apps, but Sessions seem to be the best bet.

          cheers

          Comment

          Working...