Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. hi guys , please can you tell me how can i declare a global variables ?

hi guys , please can you tell me how can i declare a global variables ?

Scheduled Pinned Locked Moved ASP.NET
questionhelp
7 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mohammed Amine
    wrote on last edited by
    #1

    HI , please i need to declare some global variables like : public con as sqlconection public DtSet as Dataset but for condition to retrieve them in each page in ma web site , i sought a lot for that stuff & i've posted a lot of questions in some furoms but nobody gave me a convinced answer can you help me please ?

    try to be good if you can't be the best

    N B T G P 5 Replies Last reply
    0
    • M Mohammed Amine

      HI , please i need to declare some global variables like : public con as sqlconection public DtSet as Dataset but for condition to retrieve them in each page in ma web site , i sought a lot for that stuff & i've posted a lot of questions in some furoms but nobody gave me a convinced answer can you help me please ?

      try to be good if you can't be the best

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Use a data access layer

      only two letters away from being an asset

      1 Reply Last reply
      0
      • M Mohammed Amine

        HI , please i need to declare some global variables like : public con as sqlconection public DtSet as Dataset but for condition to retrieve them in each page in ma web site , i sought a lot for that stuff & i've posted a lot of questions in some furoms but nobody gave me a convinced answer can you help me please ?

        try to be good if you can't be the best

        B Offline
        B Offline
        bluewavestrider
        wrote on last edited by
        #3

        You can create a class in App_Code and declare your variables as static. Hence if your class is called Database and u declared static con as sqlconnection, you can access this variable by doing: Database.conn

        Live in fragments no longer. Only connect.

        1 Reply Last reply
        0
        • M Mohammed Amine

          HI , please i need to declare some global variables like : public con as sqlconection public DtSet as Dataset but for condition to retrieve them in each page in ma web site , i sought a lot for that stuff & i've posted a lot of questions in some furoms but nobody gave me a convinced answer can you help me please ?

          try to be good if you can't be the best

          T Offline
          T Offline
          tanya foster
          wrote on last edited by
          #4

          Mohammed, Try reading through the link titled How do I store global variables? http://steveorr.net/faq/GlobalVariables.aspx Some basic steps: 1. declare a variable as you would any variable in asp.net with the Dim command 2. somewhere in code, retrieve variable as a session variable For example, Dim testGlobalVariable As Integer testGlobalVariable = 100 Session("thisIsAGlobalVariable") = testGlobalVariable ... in another page... Dim ReadGlobalVariable as Integer ReadGlobalVariable = Session("thisIsAGlobalVariable") Hope this helps.

          1 Reply Last reply
          0
          • M Mohammed Amine

            HI , please i need to declare some global variables like : public con as sqlconection public DtSet as Dataset but for condition to retrieve them in each page in ma web site , i sought a lot for that stuff & i've posted a lot of questions in some furoms but nobody gave me a convinced answer can you help me please ?

            try to be good if you can't be the best

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            See my reply in your previous thread.

            --- b { font-weight: normal; }

            1 Reply Last reply
            0
            • M Mohammed Amine

              HI , please i need to declare some global variables like : public con as sqlconection public DtSet as Dataset but for condition to retrieve them in each page in ma web site , i sought a lot for that stuff & i've posted a lot of questions in some furoms but nobody gave me a convinced answer can you help me please ?

              try to be good if you can't be the best

              P Offline
              P Offline
              prabhu dot net
              wrote on last edited by
              #6

              you can use module form to declare global variables example: public con as new sqlclient.sqlconnection public dataset as new dataset The above commands can be accessed by all forms by declaring them and placed in the public class in seperate module form ok

              coding makes me interesting in dot net

              A 1 Reply Last reply
              0
              • P prabhu dot net

                you can use module form to declare global variables example: public con as new sqlclient.sqlconnection public dataset as new dataset The above commands can be accessed by all forms by declaring them and placed in the public class in seperate module form ok

                coding makes me interesting in dot net

                A Offline
                A Offline
                Amit Agarrwal
                wrote on last edited by
                #7

                Hello, I'm making a project in asp.net with vb,i have a page named as IndividualProperty.aspx. I'm showing the listing of all the property one after it in the page.when any user select any property such as he select "abc" property, when he click on this Property the IndividualPropertypage will be called.that is ok. but i want to change the URL from www.xyz.com/IndividualPropertypage.aspx to www.xyz.com/abc.com meanwhile whatever the property he select property name must be replace the page name in the URL. How is it possible,plz tell me thanx

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups