Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted

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

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?

Posted

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

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted (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 by wyrd
Gamer extraordinaire. Programmer wannabe.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...