There are different ways to indicate the action method to which we want to submit our form. I am going to explain these methods here. You can find the following working examples here.
Submit button inside the form (default behavior)
This is the most common scenario, we have one submit button inside the form. When we submit the form, it posts back to form’s submit action,
- @using (Html.BeginForm("Enroll", "Home", FormMethod.Post))
- {
- <div class="form-group">
- @Html.LabelFor(m => m.Name)
- @Html.TextBoxFor(model => model.Name, new {@class="form-control"})
- </div>
- // form is postback to /Home/Enroll
- <input type="submit" value="Enroll" class="btn"/>
- }
Submit button outside the form
If your submit button is outside the form, you can use the form attribute to indicate the form that should be used for postback,
- @using (Html.BeginForm("Enroll", "Home", FormMethod.Post, new { id = "myFrom" }))
- {
- <div class="form-group">
- @Html.LabelFor(m => m.Name)
- @Html.TextBoxFor(model => model.Name, new {@class="form-control"})
- </div>
- }
- // submit button is outside the form, it would postback to form's postback action: /Home/Enroll
- <input type="submit" value="Enroll (outside)" form="myFrom" class="btn"/>

Kyle LeePosted Jun 6, 2022, 11:49 AM
In my case, even if the submit button was inside the form, the breakpoint inside the post action wasn't hit. After I forced it, e.g. <input type="submit" value="Save" class="btn btn-primary" formaction="@Url.Action("SaveMe")" formmethod="post" />, now it works. Thanks for saving my life!
Laxmidhar SahooPosted Dec 5, 2019, 11:01 PM
Hi A good navigation aproches descriptions
Sourav Kumar DasPosted Dec 4, 2019, 7:02 AM
Nice article.
Laxmidhar SahooPosted Dec 3, 2019, 10:54 PM
Thanks for a good article