ASP.Net MVC Razor HTML Help 範例
@{ ViewBag.Title = "RazorHelp"; } <h2>RazorHelp</h2> <h3>文字框(input type="text")</h3> @{ string defaultValue = "Default Value"; } <h5>有預設值</h5> @Html.TextBox("textBoxName", defaultValue, new { @class = "form-control" }) <h5>預設值為空</h5> @Html.TextBox("textBoxName", null, new { @class = "form-control" }) <hr /> <h3>下拉選單(select)</h3> <h5>有預設值</h5> @{ List<SelectListItem> items = new List<SelectListItem> { new SelectListItem { Text = "Option 1", Value = "1" }, new SelectListItem { Text = "Option 2", Value = "2", Selected = true }, new SelectListItem { Text = "Option 3", Value = "3" } }; } @Html.DropDownList("dropdownName", items, "Select an option", new { @class = "form-control" }) <h5...