Dialog Box

S

Simmy

I have a form that when a user clicks on submit a dialog box comes up and
wants to verify the data a user entered. Right now the dialog box only has a
"ok" button which when clicked will submit the form. Is there any way to add
a "cancel" button so that the user can change data before it is submitted.
 
S

S.Y.M. Wong-A-Ton

I'm not sure how you've set up your form, but you can use code to show a
dialog box with the desired buttons:

XDocument.UI.Confirm("Your message", 1) will give you OK/Cancel buttons
XDocument.UI.Confirm("Your message", 3) will give you Yes/No/Cancel buttons
XDocument.UI.Confirm("Your message", 4) will give you Yes/No buttons

The Confirm method will return a value and you can then take action
depending upon which value was returned. For further information, see
http://msdn2.microsoft.com/en-us/library/bb229982.aspx
 
S

Simmy

Thank you for your help. This has worked in a simple button test but I have a
more detailed question.

We are submitting to SQL with a submit button with custom rules. Our rules
perform several calculations in the form but then also bring up a standard
alert box which concatenates various fields with some fixed text, all adding
up to an informational "Are you Sure" window. Since infopath's standard
alert popup only has an OK button, and we still need other rules to fire
after the pressing of this OK button, we need to apply the
XDocument.UI.Confirm specs that you named, specifically to this alert. On the
other hand, we need all rules and submission to halt if we hit "cancel". We
are not avid coders but can certainly copy and paste with the best of 'em.
Can you please give us an idea of how to incorporate your teachings below
into the "Are you Sure" alert system we already have? Or perhaps propose an
alternative to our existing alert box? Thanks again for your help.
 
S

S.Y.M. Wong-A-Ton

Since I do not really have a very clear picture of your alert system, I
cannot really give much advice on it. In any case, I have some bad news for
you: Since rules always fire before code, you'll never be able to stop them
from within your code, so your only option will be to implement the
functionality of all the rules, which you currently have in your form, in
code to be able to use a dialog box and get control over whether certain
logic is executed or not when someone chooses to cancel an action.
 

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

Top