Hi,@Cecilia H ,
If you add asp-controller
and asp-action
to your button,it will generate to formaction
.The asp-controller
attribute assigns the controller used for generating the URL. The asp-action
attribute value represents the controller action name.Here is a simple demo:
<form>
<button asp-controller="Category" asp-action="Test" type="submit" class="btn btn-primary" style="width:150px">Create</button>
</form>
result:
So that when you clicking the button,it will submit the form and go to Category/Test
.
If you want to add asp-controller
and asp-action
to <a>
tag.it will generate to href
.
<a asp-controller="Category" asp-action="Test" type="submit" class="btn btn-secondary" style="width:150px">Back to List</a>
result:
When clicking the button,it willgo to Category/Test
without submitting the form.And for more details about anchor helper,you can refer to the official doc.
----------
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Yiyi You