2012-01-12 55 views
0

我有表與ajax分頁,我可以選擇任何頁面和查看數據,但如果我按我的瀏覽器刷新,它顯示頁面一號。如何在刷新後留在同一張桌面上?頁面刷新後Ajax分頁,行爲不正確

這是代碼的一部分。

@using (Ajax.BeginForm(new AjaxOptions() { UpdateTargetId = "users_rows", Url = Url.Action("UsersRows") })) 
    { 
     <table> 
      <thead> 
      <tr> 
       <th>@Resources.Id</th> 
       <th>@Resources.Login</th> 
       <th>@Resources.Password</th> 
       <th>@Resources.FirstName</th> 
       <th>@Resources.LastName</th> 
       <th>@Resources.Birthday</th> 
       <th>@Resources.IsActive</th> 
       <th>@Resources.Role</th> 
       <th>@Resources.RegistrationDate</th> 
      </tr> 
      </thead> 
      <tbody id="users_rows"> 
       @Html.Partial("UsersRows", Model) 
      </tbody> 
     </table> 
    } 
    @Html.Partial("Pager", Model) 

Pager.cshtml:

@model UserManagmentStudio.Domain.IPager 

@if (Model.PageCount > 1) 
{ 
    for (Int32 i = 1; i <= Model.PageCount; i++) 
    { 
     @Ajax.ActionLink(i.ToString(), "Index", new {page = i}, 
      new AjaxOptions() 
      { 
       UpdateTargetId = "users_rows", 
       Url = Url.Action("UsersRows", new { page = i }), 
      } 
     ) 
     @:&nbsp 
    } 

} 

回答

0

有沒有辦法實現這個,因爲你正在使用AJAX爲您的分頁,因此永遠不會重新加載當前頁面。如果您刪除了AJAX調用併爲您的分頁執行完全回發,則瀏覽器的URL將被更新,如果用戶點擊<kbd>F5</kbd>,他將不會追蹤當前頁面,因爲它將成爲查詢字符串的一部分。

0

當你刷新它會回到你的默認行爲。您可以將當前用戶的頁面存儲在cookie中,然後將其作爲參數傳遞給傳呼機。您必須爲每個獨特的頁面用戶訪問存儲Cookie - 它不包括尋呼機頁面,因爲它是同一個頁面。好處是你不需要在用戶離開後保留cookie。

除此之外,沒有辦法做到這一點。