conflict between validation controls and "confirm"

B

Bob D

I have a web form that uses several client side
validators when user hit submit. Now users ask me to
include a dialog box to confirm the action before
submission. I tried to add a javascript
function "confirm" to the form's onsubmit event, which
turned to be appended by VS.net to a bunch of other
validation scripts as mentioned above. Thus it couldn't
work. Does anyone have good suggestions on how to
accomplish this? I know there are work-arounds, such as
sending back a page for additional confirmation. But user
experience won't as be good.
Thanks for your help!
 
T

Teemu Keiski

Hi,
Not sure, but you could try just rewriting the onclick attribute of the
control that causes postback (is it button etc?).

Anyway this would work for sure:

on the control that causes the validation (that normally triggers it), you
could put CausesValidation="False" to remove the default validation. Then
append the confirm script and call to Page_ClientValidate (in JavaScript as
well to trigger client-side validation) to the Onclick attribute . This way
confirming happens before validation. Just on the control's postback event
(Click with buttons) make call to Page.Validate and then check Page.IsValid
to be sure about the validation both at client and at server
(CausesValidation="false" causes, as the name says, that validation isn't
triggered automatically anymore but it can still be triggered
automatically).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top