C# MVC分页,razor,view传送model
IMVCPages
interface IMVCPages
{
int GetItemsCount(); int GetPageSize(); int GetPagesCount(); /// <summary>
/// 当前页面索引,用于分页
/// </summary>
int CurrentPageIndex { get; set; }
}
View。【这里有从页面view传送Model数据到Controller的方法。】
<div>
查询到 @Model.GetItemsCount() 条记录,共 @Model.GetPagesCount()页。
@using( Html.BeginForm("JieGuo", "KaiFang", FormMethod.Post, new { id = "chaxunform"}))
{
@Html.HiddenFor(m => m.SearchSouceModel.Name);
@Html.TextBoxFor(m => m.CurrentPageIndex, new { @class="form-control hidden", id = "hiddenIndex" }); <div class="btn-toolbar" role="toolbar">
<div class="btn-group">
<button class="btn btn-default" onclick="idToIndex(0)">首页</button>
</div> <div class="btn-group">
@for (int iPageIndex = 0; iPageIndex < Model.GetPagesCount(); iPageIndex++)
{
if (iPageIndex == Model.CurrentPageIndex)
{
<button class="btn btn-primary disabled" id="@iPageIndex" onclick="idToIndex(this.id)">@iPageIndex</button>
}
else
{
<button class="btn btn-default" id="@iPageIndex" onclick="idToIndex(this.id)">@iPageIndex</button>
}
}
</div> <div class="btn-group">
<button class="btn btn-default" onclick="idToIndex(@Model.GetPagesCount() -1)" >末页</button>
</div>
</div>
} </div>
效果图

C# MVC分页,razor,view传送model的更多相关文章
- MVC Controller中View(model)如何在 View中的index页面获得?
http://bbs.csdn.net/topics/390723984?page=1 在页面顶部定义@model List<UserModel>使用@foreach(var x in M ...
- A Look at the Razor View Engine in ASP.NET MVC
The biggest architectural difference that exists between ASP.NET MVC and ASP.NET Web Forms is the ne ...
- ASP.NET MVC Controller向View传值方式总结
Controller向View传值方式总结 总结发现ASP.NET MVC中Controller向View传值的方式共有6种,分别是: ViewBag ViewData TempData 向普通Vie ...
- MVC分页
http://www.cnblogs.com/iamlilinfeng/p/4075292.html 目录 一.Contrl与View数据传递(多表数据) 二.分页控件介绍 三.MVC源码说明 四.源 ...
- Asp.Net MVC 分页、检索、排序整体实现
很多时候需要这样的功能,对表格进行分页.排序和检索.这个有很多实现的方式,有现成的表格控件.用前端的mvvm,用户控件.但很多时候看着很漂亮的东西你想进一步控制的时候却不那么如意.这里自己实现一次,功 ...
- Asp.Net MVC<八>:View的呈现
ActionResult 原则上任何类型的响应都可以利用当前的HttpResponse来完成.但是MVC中我们一般将针对请求的响应实现在一个ActionResult对象中. public abstra ...
- ASP.NET MVC 4使用PagedList.Mvc分页
ASP.NET MVC中进行分页的方式有多种,在NuGet上有提供使用PagedList.PagedList.Mvc进行分页. 1. 通过NuGet引用PagedList.Mvc 在安装引用Paged ...
- ASP.NET MVC分页实现之改进版-增加同一个视图可设置多个分页
我之前就已经实现了ASP.NET MVC分页(查看该博文),但它有局限性,必须确保在同一个视图中只能有一处分页,若需要在同一个视图中设置多个分页,却无能为力,为此,我重新对原先的代码进行了优化,增加了 ...
- MVC 中 Razor 无限分类的展示
在MVC的Razor视图展示无级分类的办法,在网上看了很多资料,大多搞得很高大上.可能本人水平有限,实在是不会用. 那我就用最简单爆力的办法来做. Model: public class NewsCa ...
随机推荐
- FileUpload的使用案例
文件上传 1.www.apache.org下载commons fileupload 和 commons io 2.创建jsp并附上如下代码 <%@ page language="jav ...
- Sql Server使用正则表达式
近日因项目需求,需要在sql server中用到正则表达式,因Sql Server本身并不支持正则表达式,需要用到Clr函数. 在此记录一下步骤,与大家共享,虽然写的是原创,但有参考网上的文章. 1. ...
- Mongodb实用网址记录
ISODate类型算出时间戳> ISODate("2012-04-16T16:00:00Z").valueOf() 1334592000000 然后根据得到的时间戳查询即可d ...
- CDZSC_2015寒假新人(1)——基础 d
Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It i ...
- 从汇编看c++初始化列表初始化成员变量
简略来说,编译器会对初始化列表按照成员变量的声明顺序重新一一排序,安插到构造函数中进行初始化操作,而且这些初始化操作在构造函数里面用户自己定义的任何代码之前. 下面是c++源码: class X { ...
- [Linux]Service mysql start出错(mysql: unrecognized service)解决方法
service mysql start出错,mysql启动不了,解决mysql: unrecognized service错误的方法如下: [hitony ~]# service mysql star ...
- Django 模板中引用静态资源(js,css等)
Django 模板中免不了要用到一些js和CSS文件,查了很多网页,被弄得略晕乎,还是官网靠谱,给个链接大家可以自己看英文的. https://docs.djangoproject.com/en/1. ...
- ACboy needs your help again!--hdu1702
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- A/B的困扰
在学会简单A+B后,在实验A/B时遇到了下面的问题. #include<stdio.h> #include<stdlib.h> int main() { int a,b; sc ...
- nginx的请求接收流程(二)
在ngx_http_process_request_line函数中,解析完请求行之后,如果请求行的uri里面包含了域名部分,则将其保持在请求结构的headers_in成员的server字段,heade ...