This is a migrated thread and some comments may be shown as answers.
RadAjaxPanel not updating __ViewState
1 Answer 35 Views
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 22 May 2012, 05:56 PM
I'm having a problem with my RadAjaxPanel and my viewstate.

We are keeping our last ten viewstates in session. The problem is on a certain page.. the user hits the page and selects a CATEGORY from a drop down. Another drop down is populated with CategoryTYPES depending on the CATEGORY that was selected.

To keep the page from posting back, I have a RadAjax panel around the controls on the page.

After selecting a CATEGORY/TYPE, the user can add that combination to a listbox and select another CATEGORY/TYPE. These selections are then used in a search that populates a RadGrid.

Our legacy system allowed the users to then use the browser back / forward buttons to move backward and forward, which loaded each viewstate version from memory. So each step was saved.

With my RadAjax panel on the page though, the hidden __VIEWSTATE value is not being updated on the page. I can see my SavePageStateToPersistenceMedium Sub is firing and that my subsequent viewstates are being saved to memory, but since the hidden field isn't being updated on the page, I'm continually loading the wrong version of the page (the original version from when I first hit the page)  after doing an actual postback.

I think my main problem is the hidden field __VIEWSTATE is not getting updated. The hidden field has no runat="server" on it since it's being put there dynamically, and although I've managed to find the control and read the value from it, I can't find a way to update it during the ajax postback.  

I've tried adding EnableViewState="true" to my ajax panel, but I'm still not updating the hidden field on the page when then ajax postback occurs.

I know I can't be the only one who's run into this and I'm hoping someone has a solution or even a work around that will allow me to keep track of where I'm at and what viewstate version I'm supposed to be loading when the user tries to browse backwards or forwards.

And yes, I know.. but they insist on being able to use the BACK and FORWARD browser buttons, so I have to live with it.  :)

I appreciate any suggestions or tips on how I can get around this problem...
~TFlick

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 28 May 2012, 08:10 AM
Hi Tim,

Note that the presented behaviour is a generic MS Ajax issue related to the browser history and it could be easily replicated using regular asp UpdatePanels instead of RadAjaxPanel control.

Generally speaking, the ajax controls are using xmlhttp requests which update silently parts of the page. The browser Back and Forward functionality is only available when a full postback has occurred and that is the reason for them not to remember the last page state after ajax request.

You can however enable the browser back and forward buttons by enabling history through the ScriptManager on the page. For more information refer to the below articles: http://msdn.microsoft.com/en-us/library/cc488548.aspx

http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.addhistorypoint.aspx

http://dotnetslackers.com/articles/aspnet/AFirstLookAtASPNETExtensions35HistoryPoints.aspx



Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Tim
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or