Razor 标签语法(1-11) Label,Text,Hidden,Password,Radio,CheckBox,DropdownList,Href,Img,Css,JS

1.1 Label
Html语法: <label for=“UserName”>用户名</label>
Razor语法: @Html.LabelFor(m=>m.UserName)
                     @Html.Label("第 + (i+ 1) + "页")
1.2 Text
Html语法: <input id=“UserName”name=“UserName”type=“text” value=“”/>
Razor语法: @Html.TextBoxFor(m=>m.UserName)
                     @Html.TextBox("LinProductId")


1.3  Hidden
Html语法:  <input id=“UserName” name=“UserName” type=“hidden” value=“”/>
Razor语法:  @Html.HiddenFor(m=>m.UserName)
@Html.Hidden("Choosed", Convert.ToString(ViewData["Choosed"]))


1.4  Password
Html语法: <input id=“UserPass” name=“UserPass” type=“password” />
Razor语法:  @Html.PasswordFor(m=>m.UserPass)
                       @Html.Password("txtPassword", "", new { @id = "txtPassword" })


1.5 Radio
Html语法:  <input id=“sex0” name=“sex” type=“radio” value=‘’0”/>男
                    <input id=“sex1” name=“sex” type=“radio” value=‘’1”/>女
Razor语法: @Html.RadioButtonFor(m=>m.sex,0,new {id=“sex0”})男
@Html.RadioButtonFor(m=>m.sex,1,new {id=“sex1”})女

@Html.RadioButton(“noLimitAge”, 0, new {@Name = “limit”, @checked = “checked”, @onclick = “clickNoLimit()”})不限制
@Html.RadioButton(“limitAge”, 1, new {@Name = “limit”, @onclick = “clickLimit()”})限制


1.6 CheckBox
Html语法: <input id=“chk1” name=“chk1” type=“checkbox” value=“true”/>
Razor语法:  @Html.CheckBoxFor(m => m.IsRemember) 下次自动登录
@Html.CheckBox("checkAll", new { id = "checkAll", onclick = "CheckAll()" })


1.7 DropdownList
Html语法: 
                    <select id="DDLDepartment" name="DDLDepartment"><option value="-1">请选择</option>
</select>
                    <select id="DDLMan" name="Man"><option value="-1">请选择</option></select>
Razor语法:   
@Html.DropDownList("DDLDepartment", new List<SelectListItem> { new SelectListItem { Text = "请选择", Value = "-1" } }, new { id = "DDLDepartment", name = "DDLDepartment" })                                                 
                       @Html.DropDownListFor(m => m.Man, new List<SelectListItem> { new SelectListItem { Text = "请选择", Value = "-1" } }, new { id = "DDLMan" })


1.8 Href
Html语法: 
                    <a href="/***/OrderProcessDetail?orderSerialId=XXX&amp;Channel=PayReminder" target="_blank">123456</a>
Razor语法:   
                   @Html.ActionLink(item.CustomerSerialId, "OrderProcessDetail", "***", new { orderSerialId = item.OrderSerialId, Channel = Request["Channel"] }, new { target = "_blank" })


1.9 Img
Html 语法 :<img src="/Content/images/1.jpg" />
Razor语法: <script src="@Url.Content("~/Content/images/1.jpg")"></script>


1.10 CSS
Html 语法 :<link href="/Content/style.css" />
Razor语法: <link href="@Url.Content("~/Content/style.css")" />


1.11 JS
Html 语法 :<script src="/Content/jquery.js"></script>
Razor语法: <script src="@Url.Content("~/Content/jquery.js")"></script>
--------------------- 
作者:chenghaibing2008 
来源:CSDN 
原文:https://blog.csdn.net/chenghaibing2008/article/details/50925122 
版权声明:本文为博主原创文章,转载请附上博文链接!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值