private static string getLinkHtml(UrlHelper urlHelper, bool useAjax, string ajaxSuccessFunction, string linkContent, string actionName, string controllerName, RouteValueDictionary routeValues)
{
string link = "";
if (useAjax)
{
link += "<a href=\"javascript:void(0);\" onclick=\"javascript:$.post('" + urlHelper.Action(actionName, controllerName) + "',{";
//将route放到post表单中
foreach (var route in routeValues.Keys)
{
link += route + ":'" + routeValues[route].ToString() + "',";
}
if (routeValues.Count > 0)
{
link = link.Remove(link.Length - 1);
}
link += "}," + ajaxSuccessFunction + ")\" >";
}
else
{
link += "<a href=\"" + urlHelper.Action(actionName, controllerName, routeValues) + "\">";
}
link += linkContent;
link += "</a>";
return link;
}
[HttpPost]
public ActionResult GoPage()
{
int pageSize = 4;
int allCount = db.Movies.Count();
ViewBag.Num = allCount;
ViewBag.PageSize = pageSize;
int pageIndex, startIndex, endIndex;
//获取开始和结束的记录序号
PagerHelper.GetStartAndEndIndex(allCount, pageSize, out pageIndex, out startIndex, out endIndex);
//调用存储过程返回指定序号范围的数据
// return View(db.SelectUserList(startIndex, endIndex)); //var sear = (from m in db.Movies where m.ID >= startIndex && m.ID <= endIndex select m).ToList();
var sear = db.Movies.OrderBy(m => m.ID).Skip(startIndex).Take(endIndex - startIndex + 1).ToList();
return View("Index", sear);
//return View(db.Movies.ToList()); }
@model IEnumerable<MvcTest.Models.Movie>
@using MvcTest.Extends
@using MvcTest.HTML @{
ViewBag.Title = "Index";
} <script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
<h2>Index</h2>
<script type="text/javascript"> function Call() {
$.post('/Movies', { page: '2' }, OnPageChanged);
} // function Hello() {
// alert("hello");
// }
</script>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<div id="dvOrders">
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Title)
</th>
<th>
@Html.DisplayNameFor(model => model.ReleaseDate)
</th>
<th>
@Html.DisplayNameFor(model => model.Genre)
</th>
<th>
@Html.DisplayNameFor(model => model.Price)
</th>
<th></th>
</tr> @foreach (var item in Model)
{
<tr>
<td>
@* @Html.DisplayFor(modelItem => item.Title)*@
@item.ID
</td>
<td>
@*@Html.DisplayFor(modelItem => item.ReleaseDate,"yyyy-MM-dd")*@
@Html.ValueFor(modelItem => item.ReleaseDate, "{0:yyyy-MM-dd}")
</td>
<td>
@Html.DisplayFor(modelItem => item.Genre)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
} </table>
@Html.Pager("GoPage", "Movies", new { }, new PagerConfig { TotalRecord = ViewBag.Num, PageSize = ViewBag.PageSize, UseAjax = true, AjaxUpdateTargetID = "dvOrders" }) </div> <!--
<input type="button" id="TestList" />
--> @section Scripts{
<script type="text/javascript"> function Format(date) { return date + "123";
} function formatNumToDate(value) {
var now = eval(value.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));///.../gi是用来标记正则开始和结束;\是转义符;()标注了正则匹配分组1,$1
var year = now.getYear() + 1900;
var month = now.getMonth() + 1;
var date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
return year + "-" + compareNine(month) + "-" + compareNine(date) + " " + compareNine(hour) + ":" + compareNine(minute) + ":" + compareNine(second);
} $(document).ready(function () {
function ChangeDateFormat(time) {
if (time != null) {
var date = new Date(parseInt(time.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return date.getFullYear() + "-" + month + "-" + currentDate;
}
return "";
}
$("#TestList").click(function () { $.getJSON("/Movies/GetAllList", {}, function (result) { alert(result);
$.each(result, function (i, field) {
//var datetime = field.ReleaseDate.formatNumToDate(); alert(i + " " + ChangeDateFormat(field.ReleaseDate)); }); });
}); });
</script>
}

C#_MVC_分页update的更多相关文章

  1. ASP.NET分页存储过程,解决搜索时丢失条件信息

    存储过程: -- ============================================= -- Author: -- Create date: -- Description: 分页 ...

  2. .NET面试题集锦②(Part 二)

    一.前言部分 文中的问题及答案多收集整理自网络,不保证100%准确,还望斟酌采纳. 1.实现产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复. ]; ArrayList my ...

  3. ASP.NET常见面试题及答案(130题)

    1.C#中 property 与 attribute(抽像类)的区别,他们各有什么用处,这种机制的好处在哪里?答:property和attribute汉语都称之为属性.不过property是指类向外提 ...

  4. .NET面试题目

    简单介绍下ADO.NET和ADO主要有什么改进? 答:ADO以Recordset存储,而ADO.NET则以DataSet表示,ADO.NET提供了数据集和数据适配器,有利于实现分布式处理,降低了对数据 ...

  5. 经典.net面试题目

    1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . private :   私有成员, 在类的内部才可以访问. protected : 保 ...

  6. net面试题

    简述 private. protected. public. internal 修饰符的访问权限.答 . private :   私有成员, 在类的内部才可以访问.   protected : 保护成 ...

  7. .net面试题集锦

    1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . private : 私有成员, 在类的内部才可以访问. protected : 保护成 ...

  8. asp.net面试题汇总

    1.静态成员和非静态成员的区别? 答: 静态变量使用 static 修饰符进行声明,在类被实例化时创建,通过类进行访问不带有 static 修饰符声明的变量称做非静态变量,在对象被实例化时创建,通过对 ...

  9. 单表60亿记录等大数据场景的MySQL优化和运维之道

    此文是根据杨尚刚在[QCON高可用架构群]中,针对MySQL在单表海量记录等场景下,业界广泛关注的MySQL问题的经验分享整理而成,转发请注明出处. 杨尚刚,美图公司数据库高级DBA,负责美图后端数据 ...

随机推荐

  1. 在 Azure 中使用公用 IP 创建多 NIC VM

    Russ Slaten  2014年 11 月 18日下午 4点 我们最近宣布了支持具有多个网络接口控制器 (NIC) 的虚拟机 (VM).我仍在努力了解此功能适用的所有新场景,但首先,我希望亲自测试 ...

  2. apache开源项目--Sirona

    Apache Sirona 为 Java 应用程序提供了一个简单但可扩展的监控解决方案. apache / sirona

  3. Java [leetcode 33]Search in Rotated Sorted Array

    题目描述: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 ...

  4. Linux串口c_cc[VTIME]和c_cc[VMIN]属性设置的作用

    Linux串口c_cc[VTIME]和c_cc[VMIN]属性设置的作用 在串口编程模式下,open未设置O_NONBLOCK或O_NDELAY的情况下. c_cc[VTIME]和c_cc[VMIN] ...

  5. Linux中的设备文件与设备号

    设备文件与设备号   在Linux下,一切皆文件,设备也不例外,为了管理这些设备,系统为它们各自都编了号,而每个设备号又分为主设备号和次设备号.主设备号用来区分不同类型的设备,而次设备号用来区分同一类 ...

  6. Apache Mina原理及典型例子分析

    Apache Mina ,一个高性能 Java 异步并发网络通讯框架.利用 Mina 可以高效地完成以下任务: TCP/IP 和 UDP/IP 通讯 串口通讯 VM 间的管道通讯 SSL/TLS JX ...

  7. Algorithm for Maximum Subsequence Sum z

    MSS(Array[],N)//Where N is the number of elements in array { sum=; //current sum max-sum=;//Maximum ...

  8. json解析之jackson ObjectMapper

    Json解析常用的有fastjson和jackson,性能上网上有不少的对比,说是fastjson比较好,今天先整理一下jackson的东西,后面再发一个fastjson的. jackson是spri ...

  9. Hadoop安装教程_单机/伪分布式配置

    环境 本教程使用 CentOS 6.4 32位 作为系统环境,请自行安装系统(可参考使用VirtualBox安装CentOS).如果用的是 Ubuntu 系统,请查看相应的 Ubuntu安装Hadoo ...

  10. linux命令getopts

    一.getopts 简介 由于shell命令行的灵活性,自己编写代码判断时,复杂度会比较高.使用内部命令 getopts 可以很方便地处理命令行参数.一般格式为: getopts options va ...