-
StackOverflow 文件
-
asp.net-mvc 教程
-
Html 助手
-
HtmlHelper 示例的詳盡列表,包括 HTML 輸出
-
@Html.Action(actionName: "Index")
output: 由名為 Index()
的動作方法呈現的 HTML
-
@Html.Action(actionName: "Index", routeValues: new {id = 1})
output: 由名為 Index(int id)
的動作方法呈現的 HTML
-
@(Html.Action("Index", routeValues: new RouteValueDictionary(new Dictionary<string, object>{ {"id", 1} })))
output: 由名為 Index(int id)
的動作方法呈現的 HTML
-
@Html.Action(actionName: "Index", controllerName: "Home")
輸出: 由 HomeController
中名為 Index()
的動作方法呈現的 HTML
-
@Html.Action(actionName: "Index", controllerName: "Home", routeValues: new {id = 1})
輸出: 由 HomeController
中名為 Index(int id)
的動作方法呈現的 HTML
-
@Html.Action(actionName: "Index", controllerName: "Home", routeValues: new RouteValueDictionary(new Dictionary<string, object>{ {"id", 1} }))
輸出: 由 HomeController
中名為 Index(int id)
的動作方法呈現的 HTML
-
@Html.ActionLink(linkText: "Click me", actionName: "Index")
輸出: <a href="Home/Index">Click me</a>
-
@Html.ActionLink(linkText: "Click me", actionName: "Index", routeValues: new {id = 1})
輸出: <a href="Home/Index/1">Click me</a>
-
@Html.ActionLink(linkText: "Click me", actionName: "Index", routeValues: new {id = 1}, htmlAttributes: new {@class = "btn btn-default", data_foo = "bar")
輸出: <a href="Home/Index/1" class="btn btn-default" data-foo="bar">Click me</a>
-
@Html.ActionLink()
輸出: <a href=""></a>
@using (Html.BeginForm("MyAction", "MyController", FormMethod.Post, new {id="form1",@class = "form-horizontal"}))
輸出: <form action="/MyController/MyAction" class="form-horizontal" id="form1" method="post">