Description:
In this example, we explain that how to handle multiple submit button in MVC form in .Net. Or how do you handle multiple submit buttons in Asp.Net MVC Framework. Alternatively, how to handle multiple submit buttons on single View in MVC.
Below is the code that are useful to handle multiple
submit button on single form in MVC.
<button class="btn btn-sm
btn-primary" type="submit" name="button" value="Save">
<i class="fa
fa-dot-circle-o"></i> Save
</button>
<button class="btn btn-sm
btn-primary" type="submit" name="button" value="Save
as New Template">
<i class="fa
fa-dot-circle-o"></i> Save as New Template
</button>
[HttpPost]
public IActionResult AddTemplate(Template objTemplate,string button)
{
try
{
if (button == "Save")
{
//Code
for Save Button
}
Else
{
//Code for Save as New Template Button
}
}
catch (Exception ex)
{
Logger.WriteLog(ex);
throw;
}
}
Grateful foor sharing this
ReplyDelete