-
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">