如何使用MVC Razor增加和减少锚标记内的@currentpage值?
@{
double pagesize = Math.Ceiling(Convert.ToDouble(@ViewData["count"]) / 10);
int currentpage = Convert.ToInt32(@ViewData["id"]);
}
<a href="/Home/Index/@currentpage-1">Prev</a>
<a href="/Home/Index/@currentpage+1">Next</a>
答案 0 :(得分:2)
<a href="/Home/Index/@(currentpage-1)">Prev</a>
<a href="/Home/Index/@(currentpage+1)">Next</a>
答案 1 :(得分:1)
使用此
@{
double pagesize = Math.Ceiling(Convert.ToDouble(@ViewData["count"]) / 10);
int currentpage = Convert.ToInt32(@ViewData["id"]);
int nextpage=currentpage+1;
int Prevpage=currentpage-1;
}
<a href="/Home/Index/@Prevpage">Prev</a>
<a href="/Home/Index/@nextpage">Next</a>
答案 2 :(得分:0)
我没有尝试,但这样的事情应该有效:
@Html.ActionLink("Next", "Index", "Home", new { id = (Convert.ToInt32(@ViewData["id"]) + 1) }, "")
@Html.ActionLink("Prev", "Index", "Home", new { id = (Convert.ToInt32(@ViewData["id"]) - 1) }, "")