Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

XDocument.View.Window.Close();

Application.Quit()
share|improve this question

migrated from stackoverflow.com 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. i.stack.imgur.com/AHcBM.png –  change picture Aug 2 '12 at 12:38

1 Answer 1

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

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