I try to implement paging with ajax function. Then I create list view and partial view. Partial view displly data list and paging link List view include keyword for earch and the partial view.
My partial view looks like:
<div id="MyList">
<div style="text-align: right">
<% for (int i = 1; i <= (int)ViewData["totalPages"]; i++)
{%>
<%= Ajax.ActionLink(i.ToString(), "AjaxList", new { page = i, keyword = ViewData["keyword"] },
new AjaxOptions { UpdateTargetId = "MyList" }, new { @class = ((i == (int)ViewData["currentPage"]) ? "selected" : "") })%>
<%} %>
</div>
...
</div>
The controller action for paging is:
[Authorize]
public ActionResult AjaxList(int? page, string keyword)
{
var results = repository.FindAll();
if ((keyword != "") && (keyword != null))
{
results = SearchByKeyword(results , keyword);
}
int cnt = results .Count();
ViewData["currentPage"] = page ?? 1;
ViewData["totalPages"] = (int)Math.Ceiling(1.0 * cnt / PageSize);
ViewData["keyword"] = keyword;
var items = results.Skip(((page ?? 1) - 1) * PageSize).Take(PageSize);
if (Request.IsAjaxRequest())
return View("MyGrid", items); // HTML fragment
else
return View(items); // Complete HTML page
}
It works fine in Firefor. No error. But it not working in IE(I use IE 7). I got the error as below:
A Runtime Error has occurred. Do you wish to debug?
Line 17:
Error:Unknow runtime error
If I choosed debug, the it goes to file MicrosoftAjax.js, in VS 2008, I got error message said
htmlfile: Unknown runtime error
How to fix this problem for IE?