asp.netmvc 前台基本控件操作
基本控件标签
① 文本框
@Html.TextBox("txtname", "电影名称", new { @class = "form-control" }); @Html.TextBoxFor(model=>model.logIp, new { @class = "form-control" });
效果图
② 多行文本框
@Html.TextArea("txtnameare", "电影剧情", new { @class = "form-control" }); @Html.TextAreaFor(model=>model.logIp, new { @class = "form-control" });
③ 下拉框
@Html.DropDownList("ddl_type", ViewBag.list as SelectList, "请选择类型", new { @class = "form-control" }) @Html.DropDownListFor(model=>model.logIp, ViewBag.list as SelectList, "请选择",new { @class= "form-control" })
④ 超链接a标签
<a href="@Url.Action("index","more_movie")">更多详情</a>
⑤ 单选框
@Html.RadioButton("radio_aa", true); @Html.RadioButtonFor(model=>model.logIp, new { @class = "form-control" });
⑥ 复选框
@Html.CheckBox("chk_one", true) @Html.CheckBoxFor(model=> model.AddCustomer,new { @class = "form-control" })
⑦ 按钮
<button class="btn btn-default" type="submit" onclick="@Url.Action("post_Index","Index")">提交</button>
⑧ 隐藏控件
@Html.Hidden("hd_id", "0"); @Html.HiddenFor(model=>model.id);