<form method="post" id="modalForm" action="/Test/TestForm" target="myframe">
<input type="text" name="id" required />
<input type="text" name="name" required />
<input type="submit" value="Post" onsubmit="alert('after post!');" />
</form>
[HttpPost]
public IActionResult TestForm(Test test)
{
return View();
}
public class Test
{
public string id;
public string name;
}
What needs to be changed, on the form, to get values to the Test class? Currently the values are null? I would like to keep it simple, without ASP.NET Core helpers.
C# provides a way to use short-hand / automatic properties where you only have to write get;
and set;
inside the property.
public class Test
{
public string id { get; set; }
public string name { get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.