I expect to receive the value of the button to a.aaa
but i get null instead
a.aaa needs to be "stackOverflow" string in [HttpPost]
controller code
public class DefaultController : Controller
{
// GET: Default
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(Class1 a)
{
return View();
}
}
model
namespace WebApplication3.Models
{
public class Class1
{
public string aaa { get; set; }
}
}
view
@model WebApplication3.Models.Class1
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<button type="button" name="aaa" id="aaa" value="stackOverflow">pressMe</button>
<input type="submit" />
}