要下载一个MvcPager.dll 版本2.0不然没有效果的
Views中:
注释:为了使每次点击搜索按钮时都跳回第一页,BeginForm扩展方法中第三个参数用new RouteValueDictionary{ {"id",""}}将页索引路由值指定为空值,否则若当前为第五页,则点击搜索按钮重新搜索后当前页仍然为第五页。
@model PagedList<Question>
<form class="form-inline"> @using (Html.BeginForm("ProblemSearchs", "Department", new RouteValueDictionary { { "id", "" } }, FormMethod.Get)) {
<span>搜索关键字:</span><input type=
"text"
name=
"kword"
value=
"@Request.QueryString["
kword
"]"
style=
"width:120px"
/>
<input type=
"submit"
value=
"搜索(S)"
accesskey=
"S"
/>
}
<span>(请输入“ss”或“aa”进行测试)</span>
<form>