How to create a button in HTML for ASP.NET MVC?

Im doing a little form for the index page.

@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
}

I thought there would be `@Html.Button or something else, and I searched on Google, but apparently they did not add it.

My question is: how can I make a button?

edit: Please note: I used ASP.NET MVC for a very short time, please forgive me for this stupid question!

+4
source share
2 answers

just enable a clean html button, it will work

like

<input type="button" value="Create" /> 

if you want the HTML button to call your MVC-controler action method. try it

<input type="button" value="Create" onclick="location.href='@Url.Action("Create", "User")'" />
+6
source

You can simply use HTML in Razor:

<input type="submit" />
<input type="button" />

HTML.

+3

All Articles