I have a Edit Template Page where we EDIT, CANCEL or PREVIEW the template as per user selection. I have implemented multiple submit button for the above functionality. But the system always routing to EDIT action method.
It should route to this location "localhost/templates/Preview" instead of "localhost/templates/edit/Preview"
I am not sure whats going wrong.
Edit Action Method:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int TemplateId, TemplateViewModel templateViewModel)
{
try
{
}
catch (Exception)
{
throw;
}
}
Preview Action Method:
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Preview(TemplateViewModel templateViewModel)
{
try
{
}
catch (Exception)
{
throw;
}
}
<form asp-controller="Templates" enctype="multipart/form-data" id="Form1">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="TemplateId" />
<table>
<tr>
<td style="padding-right:6rem">
<input type="submit" value="Save" name="Save" formaction="Edit" class="btn btn-primary" />
</td>
<td style="padding-right:6rem">
<a asp-controller="Templates" asp-action="Index" class="btn btn-primary" style="margin: 5px;">Cancel</a>
</td>
<td style="padding-right:6rem">
<input type="submit" value="Preview" name="Preview" formaction="Preview" class="btn btn-primary" formtarget="_blank" />
</td>
</tr>
</table>
</form>