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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. HashTable getting null between requests

HashTable getting null between requests

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestion
5 Posts 2 Posters 1 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.
  • C Offline
    C Offline
    C Sharp Mage
    wrote on last edited by
    #1

    Hello guys, here is what i am trying to do, i have a hashtable in a class that contains regular pairs(key,value) when i click an "Add" button i fill the hashtable, so life is good however when i try to search in the same hashtable after i fill it out , i click on a "Search" button this is where i loose the hashtable content. is there a way to keep the hashtable between page requests? i am using ASP.net 1.1 and IIS6.0 Thank you for the fast response in advance The Mage

    C 1 Reply Last reply
    0
    • C C Sharp Mage

      Hello guys, here is what i am trying to do, i have a hashtable in a class that contains regular pairs(key,value) when i click an "Add" button i fill the hashtable, so life is good however when i try to search in the same hashtable after i fill it out , i click on a "Search" button this is where i loose the hashtable content. is there a way to keep the hashtable between page requests? i am using ASP.net 1.1 and IIS6.0 Thank you for the fast response in advance The Mage

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Your class has no state between postbacks. You need to either stuff it into the session, or send it to the client in the viewstate. Someone told me yesterday that making it static would work, but I am dubious, LMK if you try it and it works.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      C 1 Reply Last reply
      0
      • C Christian Graus

        Your class has no state between postbacks. You need to either stuff it into the session, or send it to the client in the viewstate. Someone told me yesterday that making it static would work, but I am dubious, LMK if you try it and it works.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        C Offline
        C Offline
        C Sharp Mage
        wrote on last edited by
        #3

        well i did make its static and still not working i am still getting a null hash the viewstate is a good idea (performance wise) since it doesn't chew server resources but would you mind if you give me example? my example is public abstract class class1 { public Hashtable htable; public class1{ htable = new Hashtable(); } public virtual void theOperation(int operationType,ListBox theControl,string filterPair){} } public class class2 : class1 { public override void theOperation(int operationType,ListBox theControl,string textPair) { thePairList.Add(key,value); // where/how can i do the viewstate??? } Thank you The Mage

        C 1 Reply Last reply
        0
        • C C Sharp Mage

          well i did make its static and still not working i am still getting a null hash the viewstate is a good idea (performance wise) since it doesn't chew server resources but would you mind if you give me example? my example is public abstract class class1 { public Hashtable htable; public class1{ htable = new Hashtable(); } public virtual void theOperation(int operationType,ListBox theControl,string filterPair){} } public class class2 : class1 { public override void theOperation(int operationType,ListBox theControl,string textPair) { thePairList.Add(key,value); // where/how can i do the viewstate??? } Thank you The Mage

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You would need to work out how to serialise a hash table and then override loadviewstate and saveviewstate. Personally, I think sending it to the client every time is the thng to avoid, but. Thanks for confirming my thoughts on the static thing.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          C 1 Reply Last reply
          0
          • C Christian Graus

            You would need to work out how to serialise a hash table and then override loadviewstate and saveviewstate. Personally, I think sending it to the client every time is the thng to avoid, but. Thanks for confirming my thoughts on the static thing.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            C Offline
            C Offline
            C Sharp Mage
            wrote on last edited by
            #5

            well, thank you for the tip i think i will just keep looking into it The Mage

            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