MVC3 View

1 篇文章 / 0 new
author
MVC3 View
@Html.DisplayForModel()
顯示整個model

@Html.EditorForModel()
編輯整個model, 也就是以當前 model 的欄位自動產生 標籤及輸入框<input ... />.

@Html.ActionLink
1. @Html.ActionLink("linkText","actionName")
<a href="/當前頁面的 ControlName/actionName">linkText</a>
2. @Html.ActionLink("linkText","actionName",routeValues)
<a href="/當前頁面的 ControlName/actionName?key=value">linkText</a>
3. @Html.ActionLink("linkText","actionName",routeValues,htmlAttributes)
<a href="/當前頁面的 ControlName/actionName?key=value" target="_main",@class="className">
   linkText</a>
4. @Html.ActionLink("linkText","actionName","controlName")
<a href="/controlName/actionName">linkText</a>
5. @Html.ActionLink("linkText","actionName","controlName",routeValues, htmlAttributes)
<a href="/controlName/actionName?key=value" target="_main",@class="className">linkText</a>
6. @Html.ActionLink("linkText","actionName","controlName","protocol","hostName","fragment", routeValues, htmlAttributes)
<a class="className" href="http://localhost/controlName/actionName?key=value#top"
   target="_main">linkText</a>

參數值: routeValues = new { key="value" }
htmlAttributes = new{ target="_main",@class="className" } 若有與關鍵字相同變數,則需前加@
protocol = "http", hostName = "localhost", fragment = "top"
關鍵字: 
Free Web Hosting