I'm hoping someone can help me by either pointing me to a straight forward example or pointing out the error(s) in my code. I'm attempting to provide history points when a user is interacting with an ajax grid. I've started just with paging but eventually want to get this working with sorting as well.
I have a master page which defines a RadScriptManager:
On a content page I have a ScriptManagerProxy to invoke the OnNavigate event (when a browser back/forward button is clicked):
The ScriptManager_OnNavigate handler is defined as such:
On the grid's OnPageIndexChanged event handler, I set a private variable to true which is then checked in the grids OnPrerender event:
It appears that the add history point is getting created and the OnNavigate code is executing but the grid doesn't update when clicking the back button. Am I missing a crucial step? Is there an example that doesn't just point me to: http://www.telerik.com/help/aspnet-ajax/ajax-back-forward-btns.html
Thanks for any help!
I have a master page which defines a RadScriptManager:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePartialRendering="true" EnableHistory="true" EnableSecureHistoryState="false"></telerik:RadScriptManager>On a content page I have a ScriptManagerProxy to invoke the OnNavigate event (when a browser back/forward button is clicked):
<asp:ScriptManagerProxy ID="ProxyScriptManager" runat="server" OnNavigate="ScriptManager_OnNavigate" />The ScriptManager_OnNavigate handler is defined as such:
protected void ScriptManager_OnNavigate(object sender, HistoryEventArgs e) { if (e.State.Count <= 0) { // setup default state RadGrid1.MasterTableView.CurrentPageIndex = 0; RadGrid1.Rebind(); return; } string key = e.State.AllKeys[0]; string state = string.Empty; if (string.Equals(key, GridPageHistoryKey)) { state = e.State[key]; int pageIndex; if (int.TryParse(state, out pageIndex)) { RadGrid1.MasterTableView.CurrentPageIndex = pageIndex; RadGrid1.Rebind(); } } }On the grid's OnPageIndexChanged event handler, I set a private variable to true which is then checked in the grids OnPrerender event:
protected void RadGrid1_PageIndexChanged(object sender, GridPageChangedEventArgs e) { _saveState = true; }protected void RadGrid1_PreRender(object sender, EventArgs e) {if (_saveState) { if (RadScriptManager.GetCurrent(this.Page).IsInAsyncPostBack && !RadScriptManager.GetCurrent(this.Page).IsNavigating) { var state = RadGrid1.MasterTableView.CurrentPageIndex.ToString(); RadScriptManager.GetCurrent(this.Page).AddHistoryPoint(GridPageHistoryKey, state); } }It appears that the add history point is getting created and the OnNavigate code is executing but the grid doesn't update when clicking the back button. Am I missing a crucial step? Is there an example that doesn't just point me to: http://www.telerik.com/help/aspnet-ajax/ajax-back-forward-btns.html
Thanks for any help!