加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何在ASP.NET MVC的HTML中创建按钮?

发布时间:2020-12-15 08:22:22 所属栏目:百科 来源:网络整理
导读:参见英文答案 Looking for a Html.SubmitButton helper that would accept class attributes in MVC36个 我正在为索引页面制作一个小表单. @model MarketPlace.Models.Download@{ ViewBag.Title = "Index";}@using (Html.BeginForm("Index","Downloads",Syst
参见英文答案 > Looking for a Html.SubmitButton helper that would accept class attributes in MVC36个
我正在为索引页面制作一个小表单.
@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")'" />

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读