ASP.NET MVC 3.0小知识积累

1、JsonResult

 1 using System.Web.Mvc;
2
3 //public ActionResult Index()
4 public JsonResult Index()
5 {
6 var province = from p in new Models.NorthwindDataContext().Province
7 select p;
8
9 return Json(new
10 {
11 page = 1,
12 total = province.Count(),
13 rows = province.ToList()
14 },
15 JsonRequestBehavior.AllowGet
16 );
17 }

 

2、Html Helper

@Html.TextBox("UserName")    <—>    <input id="UserName" type="text" value="" name="UserName">

@Html.TextBox("UserName", null, new { id = "txtUserName" })    <—>    <input id="txtUserName" type="text" value="" name="UserName">
@Html.TextBox("UserName", null, new { id = "txtUserName", style = "width:100px;" })    <—>    <input id="txtUserName" type="text" value="" style="width:100px;" name="UserName">

@Html.TextBox("UserName", null, new { id = "txtUserName", @class = "highlight" })    <—>    <input id="txtUserName" class="highlight" type="text" value="" name="UserName">

 

@Html.ActionLink("删除", "DeletePost", new { id = item.ID }, new { onclick = "return confirm('你确定要删除该随笔?')" })

posted @ 2012-04-06 21:58  libingql  阅读(718)  评论(0编辑  收藏  举报