0

I tried XDocument.View.Window.Close(true); but it tells me "The name 'XDocument' does not exist in the current context"

I even tried thisXDocument.View.Window.Close(true); but still same error.

What other way I can close an Infopath 2010 form using code?

1

Here is how i solved this issue

  1. Added a New button and made the Action to be Submit and configured advanced area.
  2. Picked Code based and Copy all my c# code to FormEvents_Submit method
  3. Also added e.CancelableArgs.Cancel = false;

Everything is good with this setup.

1

Moving my answer from closed dupe

From client-side managed code, which is no more than add-on:

Application.Quit();

and

this.Close();

are available and work in Infopath Filler Form.

It is not available in Web Browser Form (because it is run through remote Sharepoint Server 2010's Infopath Forms Services).

Here are possible workarounds:

  • setting a bogys submit with a close on submit, calling Submit() from code
  • embedding Infopath form Web Part in ASPX page, closing it from its code

From server-side (external to Infopath code), you should pass a reference to a XML (form) document being closed

0

To close it generally try this: https://stackoverflow.com/questions/127572/how-do-i-programmatically-close-an-infopath-form-in-c

To close it in the context of a browser: http://social.msdn.microsoft.com/forums/en-US/sharepointinfopath/thread/d0ecbadb-ee93-4016-bbad-fe70eddc095e/

To get a reference to the form try using the this keyword...

Or try this.Application.Quit() to close the InfoPath application: http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.application.quit%28v=office.11%29

  • Actually, I did try all of those links you provided. NONE helped. – Maria Burton Aug 1 '12 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.