Click to See Complete Forum and Search --> : auto-refresh problem


dru987
September 6th, 2005, 01:25 PM
i have a page that has meta-refresh set up to auto refresh the page every x minutes. well when meta-refresh refreshes, it acts as if the page is loaded for the first time. so my if (!Page.IsPostBack) is being executed on the auto refresh. this then reloads my original data from the DB (.databind() to my repeater) and not the filtered data that is on the page (a different .databind() in the else statement). is there another way to auto refresh a page besides using meta?

exterminator
September 8th, 2005, 05:31 AM
Yes. This is an issue with the meta tag refresh. It acts like an initial page load and you will lose the changes (that you got after a few post backs). A solution to this is keeping the state information of the controls and even the modified datasets corresponding to your controls into the Session object. And in the Page_Load event you would need to call one extra method that would:
1. Make the viewstate property of these controls to false.
2. Restore the earlier values/data retrieving from Session (with the actual initial Page Load these session variables would not be initialized and remember to clear them when you leave the page)
3. Make the viewstate property to whatever was there initially.

I found an article about this. Have a look at it - Auto Refresh of ASP.NET Page (http://www.knowdotnet.com/articles/asppagerefresh.html). I am sure with the help of this you will be able to find a solution to your specific case.

EDIT: I suddenly realized that you case is much simpler as you simply want to call the else part after those meta tag refreshes. In this case, you could simply use one addition variable and maintain it into the Session object. Say - IsActualRefresh (boolean) and while doing this check for postback using (!Page.IsPostBack), get this session variable's value as well and hence decide upon where to go - the if part or the else part. Hope that helps. :thumb: