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. Java [Leetcode 39]Combination Sum

    题目描述: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in  ...

  2. Struts2的struts.properties文件在哪儿啊?

    老师教我们Struts2的时候叫我们建了个Struts.xml文件啊?那struts.properties呢?不需要吗? 回答1: struts.properties 是可以不要的!!!因为 stru ...

  3. HTML5 jQuery图片上传前预览

    hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images,本例子主要是使用HTML5 的File API,建立一個可存取到该file的url,一个空的img标签,ID为img0,把选择 ...

  4. android中GridView关于间距的属性值介绍

    android:columnWidth  设置列的宽度.关联的方法为:setColumnWidth(int)  stretchMode属性值的作用是设置GridView中的条目以什么缩放模式去填充空间 ...

  5. Web API-如何将Controller的返回值转换成HTTP response消息

    https://www.asp.net/web-api/overview/formats-and-model-binding/json-and-xml-serialization https://co ...

  6. js模拟键盘按键事件

    var WshShell = new ActiveXObject('WScript.Shell') WshShell.SendKeys('{ }'); 说明:大括号内的是键盘上的按键如: 空格:{ } ...

  7. Colors

    .custom_a1, .custom_a2, .custom_a3, .custom_a4{ width:800px; height:100px; line-height:100px; color: ...

  8. Android 网络权限配置

    Android开发应用程序时,如果应用程序需要访问网络权限,需要在 AndroidManifest.xml 中加入以下代码 <uses-permission android:name=”andr ...

  9. Linux Shell 数学运算

    Linux Shell 数学运算 在Linux中直接使用数学运算符进行数学运算往往得不到我们想要的计算结果.要在Shell中进行数学运算,我们需要借助点小手段.目前,Linux Shell中进行数学运 ...

  10. 【bzoj2440】完全平方数

    题意: 求第n个不为完全平方数倍数的数 题解: 网上有人说答案不会超过2n (求证0 0?) 竟然不超过2n 那么很明显就是用二分做了 二分判定就是要求小于等于n的合法的数的个数 不难发现一个数若为完 ...