I have a radgrid with several pages, and on each page there are hyperlinked row values that navigate the user away from the grid to another page (like Google). What I would like to do is persist the last page viewed so that when the user clicks the back button, I return to the last page viewed and not the first page. Here's a sample page.
I've tried turning viewstate off on the grid but that doesn't seem to change the behavior. Rebinding in the Navigate event doesn't update the grid (because it's ajaxed). Maybe I'm overlooking something pretty simple and I'm open to alternative means of accomplishing the same behavior. If anyone has some suggestions, I'm grateful. Thanks.
<%@ Page Language="vb" AutoEventWireup="false" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><script runat="server"> Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource Dim table As New System.Data.DataTable Dim i As Integer table.Columns.Add("ContactID") table.Columns.Add("FirstName") table.Columns.Add("LastName") table.Columns.Add("ContactType") table.Columns.Add("PostedDate") table.Columns.Add("Replied") For i = 1 To 50 table.Rows.Add(i, i, i, i, DateTime.Now, i) Next RadGrid1.DataSource = table End Sub Protected Sub RadGrid1_PageIndexChanged(ByVal source As Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs) RadScriptManager1.AddHistoryPoint("p", e.NewPageIndex) End Sub Protected Sub ScriptManager_Navigate(ByVal sender As Object, ByVal e As System.Web.UI.HistoryEventArgs) Handles RadScriptManager1.Navigate If e.State.Count <= 0 Then ' Default state RadGrid1.CurrentPageIndex = 0 Else Dim key As String = e.State.AllKeys(0) If key = "p" Then Dim state As String = e.State(key) RadGrid1.CurrentPageIndex = CInt(state) RadGrid1.Rebind() End If End If End Sub</script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1" EnableAJAX="true" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"> </telerik:RadAjaxLoadingPanel> <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="true" PageSize="25" PagerStyle-Mode="NextPrevAndNumeric" EnableViewState="true"> <PagerStyle AlwaysVisible="True" Position="TopAndBottom" /> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings> <GroupingSettings CaseSensitive="false" /> <MasterTableView DataKeyNames="ContactID,Replied"> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <HeaderStyle Font-Bold="true" /> <Columns> <telerik:GridBoundColumn DataField="ContactID" HeaderText="ContactID" Visible="false" UniqueName="ContactID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" UniqueName="FirstName" Visible="true"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="LastName" UniqueName="TemplateColumn"> <ItemTemplate> <a href='http://www.google.com'> <%#Eval("LastName")%></a> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="ContactType" HeaderText="Contact Type" Visible="true" UniqueName="ContactType" AllowFiltering="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PostedDate" HeaderText="Posted Date" Visible="true" UniqueName="PostedDate" AllowFiltering="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Replied" HeaderText="Replied" Visible="true" UniqueName="Replied"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Delete" UniqueName="Delete" AllowFiltering="false"> <ItemTemplate> <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/Images/deletes.gif" ToolTip="Delete" CommandName="Deletes" Style="cursor: hand" /> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center"></ItemStyle> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Reply/View" UniqueName="View" AllowFiltering="false"> <ItemTemplate> <asp:ImageButton ID="btnView" runat="server" ImageUrl="~/Images/views.gif" ToolTip="Reply/View" CommandName="Reply" Style="cursor: hand" /> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center"></ItemStyle> </telerik:GridTemplateColumn> <telerik:GridClientSelectColumn ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" UniqueName="Chk_DeleteAll"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridClientSelectColumn> </Columns> </MasterTableView> </telerik:RadGrid> </form></body></html>I've tried turning viewstate off on the grid but that doesn't seem to change the behavior. Rebinding in the Navigate event doesn't update the grid (because it's ajaxed). Maybe I'm overlooking something pretty simple and I'm open to alternative means of accomplishing the same behavior. If anyone has some suggestions, I'm grateful. Thanks.