This is a migrated thread and some comments may be shown as answers.

RadAjax losing state change on page back

1 Answer 65 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 17 Dec 2008, 12:33 AM
Hi,

I have encountered an issue when using RadAjaxManager and now that I have a fix I was thinking that others might be interested.

A lot of the stuff below is detail - the same scenario is probably applicable with most control combinations.

The environment is asp.net 2.0 + VS2008 + RadControls Q3 2008 (1125)
The scenario is as follows...

1) Page with RadAjaxManager, 2 RadSliders, RadMenu, RadGrid, asp Timer (all ajaxified via RadAjaxManager)
2) RadMenu command updates the visibility of the RadSliders (shows one hides the other) and Rebinds the grid to display a different range of data.
3) Timer fires every 5 minutes or in 20 seconds from first page display

so far so good...
Now the problem happens like this.

1) Open the page (page displays in one of two modes depending on value stored in database and reflected in Menu)
2) Click on Menu to change mode - RadSliders change visibility and RadGrid rebinds ok
3) Click on page link to go to another page
4) Click 'Back' button on browser to go back to the first page
5) First page displays the ORIGINAL MODE (ie the one before the change was made via the Menu) UNTIL the timer fires.
6) When the timer fires (an ajax request) the display goes back to what it should be (ie the new mode is shown in the visibility of the RadSliders and the data in the RadGrid)

The issue is that the page is being cached and the caching is not updated as a result of the ajax changes. The fix is to turn off page caching using the following courtesy of  A Thorough Examination of "Disabling the Back Button." By Akhilesh Reddy 

<%
  Response.Buffer = true;
  Response.ExpiresAbsolute = DateTime.Now - new TimeSpan(0, 0, 1);
  Response.Expires = 0;
  Response.CacheControl = "no-cache";
%>
Once that is done everything seems to work fine. The page goes back to the server when the Back button is clicked and the state is correct.

Cheers
Steve

1 Answer, 1 is accepted

Sort by
0
Poo Preaw
Top achievements
Rank 1
answered on 25 Dec 2009, 10:26 AM
Thanks ;)
Tags
Ajax
Asked by
Stephen
Top achievements
Rank 1
Answers by
Poo Preaw
Top achievements
Rank 1
Share this question
or