How to fetch HTML Input Id in code behind ASP.Net MVC ? Either on Controller or on Model ?
view / .cshtml
<button type="submit" id="previewButton" >Preview</button>
JQuery : - This will not be in use.
$("button").click(function ()
{
var btn = this.id;
alert(btn);
}
In Controller :
[HttpPost]
public ActionResult New(MyViewModel viewModel, string clickedButton)
{
var vm = clickedButton;
return View(vm);
}
MyViewModel
public string clickedButton { get; set; }