標籤:關鍵字 hello style 標籤
1,
@Html.TextBox("txt", "hello", new { style = "width:1000px;height:1000px;" })
產生標籤:
<input id="txt" name="txt" style="width:1000px;height:1000px;" type="text" value="hello" />
2,
特殊屬性(class:c#保留關鍵字)
@Html.TextBox("txt", "hello", new { style = "width:1000px;height:1000px;",@class="aa" })
產生標籤:
<input class="aa" id="txt" name="txt" style="width:1000px;height:1000px;" type="text" value="hello" />
3,
帶串連字元的屬性(例如:data_result)
@Html.TextArea("text", "hello", new { data_result ="data"})
產生標籤:
<textarea cols="20" data-result="data" id="text" name="text" rows="2">hello</textarea>
4,
@using (Html.BeginForm()){ <input type="submit" value="Create" />}
產生標籤:
<form action="/storemanager" method="post">
<input type="submit" value="Create" />
</form>
==================添加輸入元素
[email protected]
@Html.TextBox("Title", string.Empty)//單行輸入
產生標籤:
<input id="Title" name="Title" type="text" value="" />
[email protected]
@Html.TextArea("Title", string.Empty)//多行輸入
產生標籤:
<textarea cols="20" id="Title" name="Title" rows="2">
[email protected]
@Html.Label("Title","請輸入:")
產生標籤:
<label for="Title">請輸入:</label>
---- @Html.ListBox(可以多項選擇)
@{ List<string> listbox = new List<string>(); listbox.Add("a"); listbox.Add("b"); listbox.Add("c"); } @Html.ListBox("listitem", new SelectList(listbox,"a"))
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/54/68/wKiom1SBVivyf9EsAAAMT2-8rBs194.jpg" title="搜狗20141205145501.png" alt="wKiom1SBVivyf9EsAAAMT2-8rBs194.jpg" />
控制器代碼:
// 集合 ,值欄位,文字欄位,選定的值ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId);
視圖代碼:
本文出自 “程式猿的家--Hunter” 部落格,請務必保留此出處http://962410314.blog.51cto.com/7563109/1586703
MVC3----輔助方法的使用