Close() not supported in OnSwitchView? - InfoPath Dev
in

InfoPath Dev

Close() not supported in OnSwitchView?

Last post 03-25-2008 12:24 PM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-21-2008 07:47 AM

    Close() not supported in OnSwitchView?

    Hey everyone,

    I am performing an action in jscript everytime a certain view is chosen. So in the OnSwitchView I have placed an if statement as follows;

    if (XDocument.View.Name == "Email Submit")
    {
          //Perform action
    }

    My problem is I have tried placing a close() method in this if statement once the action has been completed. However, I always get an error! The code I use for the close is;

     XDocument.View.Window.Close(true);

     I know the coding for the if statement and close method are correct when used separately, so my question is can a close method not be put into an OnSwitchView event handler?

    I'm predicting the answer to this post is going to be a quick and painfull 'no'.

  • 03-21-2008 10:15 AM In reply to

    Re: Close() not supported in OnSwitchView?

    There are many things that cannot be done during a view switch -- including switching to another view during a view switch (i.e. redirecting the view switch elsewhere). Closing is also not likely available during that event.

    However you can place a button in the view (I know--not what you want to do--not automated enough) that the user can click in the new view, which will close the form.

    You can also look at the OnContextChange event and probably close in there. The context gets changed when a view is switched (unless, perhaps--I'm not sure--there is no controls in the view). Anyway, in this handler, you can check to see if the view name is "Email Submit" and if it is, then close the form). The context event is fired late enough that all your other processing should be completed first.

    Give it a try and let me know.

  • 03-25-2008 06:31 AM In reply to

    Re: Close() not supported in OnSwitchView?

    Hey Greg,

    I gave the OnContextChange a go but unfortunatly no luck. I ended up just putting a button to close the form, as you said not ideal, but it was included strategically (if I may say so myself) so that it adds to the astetics of the view.

    Trying these things out is a good way to learn about the programming side of things so I really appreciate your suggestions.

  • 03-25-2008 12:24 PM In reply to

    Re: Close() not supported in OnSwitchView?

    Happy to be able to offer the suggestions. I hope you are enjoying the learning process despite the deadlines.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.