"Back" button and ViewState

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

Most of you might be familiar with this problem i.e, viewstate is lost
whenever we navigate from the one page to another. Does anyone have a remedy
for this problem?

On Page A, I have a datalist which has a "select" link for each row(I have
1000's of such rows). When a user clicks a particular select link, I am
redirecting him to Page B(this redirection is being done in
Datalist_ItemCommand). Once on Page B, when user clicks "Back" button in the
browser and clicks on another "Select" link, the datalist_ItemCommand is not
being fired. He is forced to click the "Select" link twice.

Does anyone for any alternatives for this problem?

Thanks!
 
When user clicks on "Back" button, the page is being served from the
browser's cache. The server does not get a chance to participate. You can
disable page caching on client by adding the required pragma settings in
headers. This should help.
 
Hello Naveen,

When I tried adding the following line of code:
Response.Cache.SetCacheability(HttpCacheability.NoCache);

to prevent the browser from caching the page. When I did this, I got this
error message in IE:

-----
Warning: Page has Expired The page you requested was created using
information you submitted in a form. This page is no longer available. As a
security precaution, Internet Explorer does not automatically resubmit your
information for you.

To resubmit your information and view this Web page, click the Refresh
button.
------

In Firefox, I am getting a "page cannot be displayed" error.

Any pointers?

Thank you.
 
Thus wrote Diffident,
Hello Naveen,

When I tried adding the following line of code:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
to prevent the browser from caching the page. When I did this, I got
this error message in IE:

-----
Warning: Page has Expired The page you requested was created using
information you submitted in a form. This page is no longer available.
As a
security precaution, Internet Explorer does not automatically resubmit
your
information for you.
To resubmit your information and view this Web page, click the Refresh
button. ------

In Firefox, I am getting a "page cannot be displayed" error.

That's not an error. It's just a warning that going "back" means resending
previously submitted data again, which might be harmful if your web application
doesn't deal with such a case.

Cheers,
 
Thus wrote Diffident,
Joerg,

Do you know how I can disable this warning in IE?

You cannot disable that warning. Instead, think about a server-side solution
to avoid that warning, like using Redirect-After-Post.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top