Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ViewState, Dynamic UserControls, and the Back Button

Reply
Thread Tools

ViewState, Dynamic UserControls, and the Back Button

 
 
John Hamm
Guest
Posts: n/a
 
      11-07-2003
My web application dynamically creates a UserControl and saves it to a
Session variable called LastControl. When a postback occurs, I simply
load the LastControl and everything works great.

The problem occurs when the user hits the Back button. Then the
"LastControl" might be a different User Control and so when I reload
it, it causes instance errors since the user control it is expecting
is no longer in a Session variable.

Some solutions I have thought about are:

1. Creating a Session variable for each User Control and keeping it in
memory. I am afraid, though, that this could tax the web server's
memory, and this just seems like a kludgy solution.

2. Figure out a way to save the User Control and put it in the page's
ViewState. This would be ideal because then I would simply load the
dynamic control from the current page's view state and there would
never be an issue with the back button and no memory would be taken up
on the server.


Has anyone had success storing a User Control in a page's view state?
 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      11-08-2003
My preferred solution would be to create the contorl every time you need it.

If that is too expensive, is the control different for each user? If not,
maybe you can use the Cache object instead of session. This way, you only
keep one copy and can better afford to keep older data around.

Jeff

"John Hamm" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> My web application dynamically creates a UserControl and saves it to a
> Session variable called LastControl. When a postback occurs, I simply
> load the LastControl and everything works great.
>
> The problem occurs when the user hits the Back button. Then the
> "LastControl" might be a different User Control and so when I reload
> it, it causes instance errors since the user control it is expecting
> is no longer in a Session variable.
>
> Some solutions I have thought about are:
>
> 1. Creating a Session variable for each User Control and keeping it in
> memory. I am afraid, though, that this could tax the web server's
> memory, and this just seems like a kludgy solution.
>
> 2. Figure out a way to save the User Control and put it in the page's
> ViewState. This would be ideal because then I would simply load the
> dynamic control from the current page's view state and there would
> never be an issue with the back button and no memory would be taken up
> on the server.
>
>
> Has anyone had success storing a User Control in a page's view state?



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
After gmail logs out, cannot go back through browser back button Author ASP .Net 6 01-22-2009 03:24 PM
Firefox back button takes me back 2 pages. Useful Info Javascript 0 06-02-2007 11:21 PM
How does a dynamic control load post back data across post back?? =?Utf-8?B?Z29yaWxsYQ==?= ASP .Net 1 05-25-2007 05:02 AM
image button as a back button Chicagoboy27 ASP .Net 2 10-30-2006 05:00 PM
disable the back button provide the users with my own button to go back. sylvia sil ASP .Net 1 12-29-2004 04:41 PM



Advertisments