ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Confirm Dialog for Popup form
Title:
B
I
{code}
?
Hi, I want to add a confirm dialog when clicking on the OK button in a popup form, but I don't know how to tap into the ok button's onclick event since I am using the "usedefaultbuttons" option
Save Changes
Cancel
Sean
asked at 14 Sep 2015
you could set UseDefaultButtons(false) and define your own buttons, and the custom ok button will show the confirm dialog and only submit the form if the users confirms it
at 14 Sep 2015
Omu
If I use custom buttons, how should I impletement the onclick to have the same postback behavior as the defaults has?
at 14 Sep 2015
Sean
Answers
B
I
{code}
?
here's an example: @(Html.Awe().InitPopupForm() .Name("confirmedPopup") .Height(400) .Url(Url.Action("Create", "DinnersGridCrud")) .UseDefaultButtons(false) .Button("Submit", "confirmSubmit")) <button type="button" onclick="awe.open('confirmedPopup')" class="awe-btn">Open popup</button> <script> function confirmSubmit() { var $this = $(this); if (confirm("are you sure")) { $this.find('form').submit(); } } </script>
Save Changes
Cancel
Omu
answered at 14 Sep 2015
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