SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to close an infopath form in C# style?

I am trying to close the browser (aka where infopath form is loaded) with managed code. I tried some for variation below but getting error and unable to compile the code.

thisXDocument.View.Window.Close(); - Gives me "Invalid token '(' in class, struct, or interface member declaration" if I put the code about 2 curly bracket at end end.

if i put the above code just before }); then i get following error.

"'XDocument' does not exist in the current context "

Same things happens with following alternatives


share|improve this question

migrated from Aug 2 '12 at 16:15

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Anders Rask Aug 2 '12 at 16:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

just fyi: this.application.quit or application.quit dont even show up. see this print shot. – change picture Aug 2 '12 at 12:38

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




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).

Possible workarounds

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

share|improve this answer