ASP.NET MVC htmlHelper
比如要访问UserInfo/Index
@Html.ActionLink("超级链接的文本","Index","UserInfo" ,new {name="itcast"},new {ID="ssss"} )
查看源码:
<a ID="ssss" href="/UserInfo?name=itcast">超级链接的文本</a>
textbox checkbox
@Html.TextBox("User","你好") @Html.CheckBox("hh",true);
扩展方法
QueryString与html
@Html.ActionLink("这是一个连接", "Index", new { page = 1 }, new { id = "link1" })
TextArea
<%=Html.TextArea("input5", Model.CategoryName, 3, 9,null)%> <%=Html.TextAreaFor(a => a.CategoryName, 3, 3, null)%> 生成结果: <textarea cols="9" id="input5" name="input5" rows="3">Beverages</textarea> <textarea cols="3" id="CategoryName" name="CategoryName" rows="3">Beverages</textarea>
DropDownList
<%= Html.DropDownList("ddl1", (SelectList)ViewData["Categories"], "--Select One--")%> <%=Html.DropDownListFor(a => a.CategoryName, (SelectList)ViewData["Categories"], "--Select One--", new { @class = "dropdownlist" })%> 生成结果: <select id="ddl1" name="ddl1"> <option value="">--Select One--</option> <option value="1">Beverages</option> <option value="2">Condiments</option> <option selected="selected" value="3">Confections</option> <option value="4">Dairy Products</option> <option value="5">Grains/Cereals</option> <option value="6">Meat/Poultry</option> <option value="7">Produce</option> <option value="8">Seafood</option> </select> <select class="dropdownlist" id="CategoryName" name="CategoryName"> <option value="">--Select One--</option> <option value="1">Beverages</option> <option value="2">Condiments</option> <option value="3">Confections</option> <option value="4">Dairy Products</option> <option value="5">Grains/Cereals</option> <option value="6">Meat/Poultry</option> <option value="7">Produce</option> <option value="8">Seafood</option>