@model 表示强类型
@{ Razor语句 }
@Html。ActionLink(“链接文本”,“Action方法”)
@Html。ActionLink(“链接文本”,“Action方法”,new{ 路由值 })
制作列表:
@Html。DisplayNameFor(model=>model.属性)//显示 模型的显示名称,字段名
@Html。DisplayFor(modelItem->item.属性)//显示 对象的属性
@foreach(var item in Model){ }//Razor的循环语法
制作提交表单
@using(Html。BeginForm()){ 表单内容 }
@Html。AntiForgeryToken()//验证,防伪标记,提交表格时验证此字段
@Html。ValidationSummary()//验证消息
@Html。LabelFor(model=>model.Title(属性),htmlAttributes:new{ @class = “control-label col-md-2”})
//html标签label
@Html。EditorFor(model=>model.Title(属性),new{htmlAttributes = new{ @class=“form-
control”}})//html输入框input
@Html。ValidationMessageFor(model=>model.Title,“字符串”,new{@class=“text-danger”})//验证信息
@section Script{ 脚本区域 }
@Script.Render(“脚本路径”)
@{ Razor语句 }
@Html。ActionLink(“链接文本”,“Action方法”)
@Html。ActionLink(“链接文本”,“Action方法”,new{ 路由值 })
制作列表:
@Html。DisplayNameFor(model=>model.属性)//显示 模型的显示名称,字段名
@Html。DisplayFor(modelItem->item.属性)//显示 对象的属性
@foreach(var item in Model){ }//Razor的循环语法
制作提交表单
@using(Html。BeginForm()){ 表单内容 }
@Html。AntiForgeryToken()//验证,防伪标记,提交表格时验证此字段
@Html。ValidationSummary()//验证消息
@Html。LabelFor(model=>model.Title(属性),htmlAttributes:new{ @class = “control-label col-md-2”})
//html标签label
@Html。EditorFor(model=>model.Title(属性),new{htmlAttributes = new{ @class=“form-
control”}})//html输入框input
@Html。ValidationMessageFor(model=>model.Title,“字符串”,new{@class=“text-danger”})//验证信息
@section Script{ 脚本区域 }
@Script.Render(“脚本路径”)