How to get the value of an input button in an ASP.NET Core MVC controller?
This is my html code in the view
<html>
<body>
<form asp-controller="Home" asp-action="GetstartTime" method="post" id="TableF">
<input id="1" name="f1" form="TableF" class="btn btn-primary" type="submit" value="12:00 PM"/>
<input id="2" name="f2" form="TableF" class="btn btn-primary" type="submit" value="2:00 PM"/>
<input id="3" name="f3" form="TableF" class="btn btn-primary" type="submit" value="3:00 PM"/>
</form>
</body>
</html>
in the razor:
<form asp-controller="Controller" asp-action="PostData">
<input id="f0" name="f0" form="TableF" class="btn btn-primary" type="submit" value="12:00 PM"/>
</form>
in the controller:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> PostData(string f0)
{
var buttonvalue =f0;
}
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.