Showing posts with label iframe viewstate loss. Show all posts
Showing posts with label iframe viewstate loss. Show all posts

Friday, November 21, 2008

IFrame ViewState or PageState lost

Hi Readers,

Do you encounter ViewState or PageState loss in your ASP.Net pages inside IFrame? In my project, I encountered this kind of issue maybe because I used PageStatePersister as the base class of my ASP.Net pages and together with AJAX. I tried to include SavePageStateToPersistenceMedium and LoadPageStateToPersistenceMedium overrided methods in my PageStatePersister base class, but it didn't help me either.

So, what I did is:
In the top of the ASP.Net Page Source Code, after the I added Update Panel . Inside that Update Panel, I added a Timer Control with Interval="5000" (equal to 5 seconds) and with OnTick event property (but you can use without OnTick event property). So that I didn't see the page refreshing, I put my ASP Timer inside the Update Panel. Then, it really solves my problem.

Here is the Example:

<body>
<ajaxtoolkit:toolkitscriptmanager id="tsmMaster" runat="server" enablepartialrendering="true"></ajaxtoolkit:toolkitscriptmanager>
<asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional" rendermode="Inline">
<contenttemplate>
<asp:timer id="tmTimer" runat="server" interval="5000" ontick="tmTimer_Tick"></asp:timer>
</contenttemplate>
</asp:updatepanel>
...
...
...
</body>



Here is my conclusion:
Inside my IFrame, I noticed that the ViewState/PageState of my ASP.Net page always loss within less than 30 seconds without any execution/event in the page (imagine < 30 secs.).

Since every 3 secs the page is being PostBack using ASP Timer, it keeps the ViewState or PageState alive.


I hope this would help your problem in dealing with Iframe, AJAX and PageStatePersister in ASP.Net.



Thanks

Best Regards,
Shaper Jabneel