我正在为索引页面制作一个小表单。
@model MarketPlace.Models.Download
@{
ViewBag.Title = "Index";
}
@using (Html.BeginForm("Index", "Downloads", System.Web.Mvc.FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<td>@Html.DisplayNameFor(model => model.EMail)</td>
<td>@Html.TextBoxFor(model => model.EMail, new { @class = "form-control round-input", @style = "width:200px" })</td>
<td>@Html.DisplayNameFor(model => model.Reference)</td>
<td>@Html.TextBoxFor(model => model.Reference, new {@class = "form-control round-input", @style = "width:200px"})</td>
<td>@Html.DisplayNameFor(model => model.Products)</td>
<td>@Html.Buttonorsomething
}
我以为会有一个`@Html.Button或其他东西,我在Google上搜索,但显然他们没有添加一个。
我的问题是,我该如何制作一个按钮?
编辑:请注意,我一直在使用ASP.NET MVC很短的时间,请原谅我这个愚蠢的问题!
只需包含纯HTML按钮就可以了
喜欢
<input type="button" value="Create" />
如果你想要一个HTML按钮,那么它将调用你的MVC控制器的动作方法。试试这个
<input type="button" value="Create" onclick="location.href='@Url.Action("Create", "User")'" />
注意:最佳做法是避免使用突出的Javascript,您可以将其作为单独的onclick
方法。
更新:
如果你真的想要一个帮助器,那么你可以创建一个自定义辅助类类型MvcHtmlString
一个很好的例子,你可以找到here
你可以在Razor中使用HTML:
<input type="submit" />
<input type="button" />
每个HTML元素都没有帮助器。