Wednesday, December 12, 2007

InfoPath: How to exit from a browser form and suppress the "save changes" dialog

If you create a browser-based InfoPath 2007 form and use a programmatic submission procedure instead of the built-in submit button, the user may get a "save changes?" prompt when clicking the Close button on the form's toolbar. There are several ways you could avoid this in InfoPath 2003. One would be to set the form's dirty bit to false using the setDirty() method. Another is to programmatically close the form with your own button. I have not seen code to do either of these things in 2007 with managed C# code. Here is my workaround:

Create a button on the form. Add a rule to the button that closes the form on click. Unhide the button when the user clicks your custom submit button.

No comments: