zoukankan      html  css  js  c++  java
  • 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 = "100px;" })    <—>    <input id="txtUserName" type="text" value="" style="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('你确定要删除该随笔?')" })

  • 相关阅读:
    流程控制之while循环
    流程控制之if...else
    基本运算符
    基本数据类型
    注释
    用户交互
    常量
    test
    查询方法
    删除代码
  • 原文地址:https://www.cnblogs.com/libingql/p/2435378.html
Copyright © 2011-2022 走看看