ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Popup Form with multiple submit buttons
Title:
B
I
{code}
?
I want to create popup form with multiple submits (use `formaction` ). If i create popup with InitPopupForm, than formaction ignored and submit always send to action from <form asp-action="" asp-controller="Reports"> @using (Html.Awe().BeginContext()) { @Html.EditorFor(a => a.DateFrom) @Html.EditorFor(a => a.DateTo) @Html.EditorFor(a => a.Login) <button asp-action="AnotherAction1" asp-controller="Reports">Report1</button> <button asp-action="AnotherAction2" asp-controller="Reports">Report2</button> } </form> Buttons always send to Reports/Index. If i create popup with InitPopup, formaction work correctly, but here is problem with validation. `return PartialView("Index", model);` redirects to page instead of replacing the popup content.
Save Changes
Cancel
Evgeny Alekseev
asked at 01 Oct 2021
Answers
B
I
{code}
?
The PopupForm OK/submit button will post the first form it finds inside the popup, and the form will be posted to it's action attribute ( generated html action attribute ). When you use the simple Popup there's no js code preventing the native submit. You could set `.UseDefaultButtons(false)` on the PopupForm and add your own buttons using `.Button("Submit", "submit1")` and in the js function for the button you could set the form's action attribute before submit <div id='form1'> <form> ... </form> </div> function submit1(){ $('#form1 form').attr('action', '@Url.Action("Action123")').submit(); }
Save Changes
Cancel
Omu
answered at 01 Oct 2021
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK