TheWizardofInt Posted March 20, 2003 Posted March 20, 2003 I am obviously doing this wrong I will declare an array as public in the class for the form I am using on the page Within a sub procedure that is also public within the class, I will redim the array and fill it with information The next time I call the array, it has a value of nothing. Any idea why? Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
LittLe3Lue Posted March 21, 2003 Posted March 21, 2003 rediming an array clears it, im not sure about aspx, but preserve keyword after the the redim in vb leaves the values like, redim preserve .. etc etc as u normaly would Quote If you think that you think, but you really can't think, were you even thinking at all? Or was it just a thought, that you had been thinking a thought, that could not have been thought at all. think about my thought... why not?
Moderators Robby Posted March 21, 2003 Moderators Posted March 21, 2003 When you call the array (the next time) is it after Posting the page? If not, then follow Little3Lue's advice. Quote Visit...Bassic Software
TheWizardofInt Posted March 23, 2003 Author Posted March 23, 2003 I create the array in the PageLoad and it is fine until the next event, which seems to wipe out the array The preserve command didn't work. I also tried Friend sRecArr as ArrayList and that didn't keep it from being wiped out either It doesn't go back through the page load after the first time, and I am using the code behind method Thanks Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
wyrd Posted March 23, 2003 Posted March 23, 2003 (edited) Any objects or variables you declare are only stored on the servers memory until the page finishes loading. You have to remember that ASP.NET is a web language, and should be treated as such. It's not like an application (unless you actually specify it to be). If you want you can store objects in memory permanently for re-use. This is dangerous though if not used properly, because you can suck up a lot of memory on your server if a ton of users access that page. A few ways to keep objects in memory (or pass pass them along); - Use application state (look up the Application object). - Use the cache (look up Cache object). - Cookies (look up HttpCookie object). - Sessions state (look up Session object). - View state (look up ViewState object). The session state or view state is probably your best option. Edited March 24, 2003 by wyrd Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.