how to close views programatically - InfoPath Dev
in

InfoPath Dev

how to close views programatically

Last post 01-17-2009 12:41 AM by Shiva. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 11-24-2008 07:08 PM

    how to close views programatically

    how can i close infopath views programatically. i am using c# in vsta.

     thanks

     

  • 11-24-2008 07:54 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: how to close views programatically

    Hi,

    You can use the following code line to close the form.

    thisXDocument.View.Window.Close(true);

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 11-24-2008 11:26 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: how to close views programatically

    Hello,

    Closing InfoPath form view means we have to shift one view to another view. At a time we can see only one in InfoPath. Above Anuma given code is for close the InfoPath form.

  • 11-25-2008 03:21 AM In reply to

    Re: how to close views programatically

    I am working on C# as programming language in infopath 2007 so above code will not work for c#.

     How can I close the view using C# in infopath 2007?

     Thanks

  • 11-25-2008 04:01 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: how to close views programatically

    Hi,

    Below code will work to close the Infopath2007 form.

    this.Application.ActiveWindow.Close();

    If you working on browser form, then it will not work. You need to add the rule to close the form.

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 11-25-2008 05:05 AM In reply to

    Re: how to close views programatically

    I want to close view and not form. Is there a way to close a view using C# in infopath 2007?

  • 11-25-2008 05:19 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: how to close views programatically

    Hi,

    Close view means, do you want to switch to other view.

    As of my knowledge there is no way to close one single view. Because form will open in one view.

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 11-25-2008 05:29 AM In reply to

    Re: how to close views programatically

    one form can have many views in it. my intention was to close the view when i am moving out of that view. for example if i am in insert view and i have inserted some records in database and when i press save button i want insert view to get closed so that if i am opening the insert view again values in insert view should get cleared instead of code clearing the each form individually.

     that's why i wanted to close the view. is there any way to close the view in c#?

  • 11-25-2008 06:01 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: how to close views programatically

    I don't know how to close the view. But below is the once option to refresh the page.

    If you want to refresh the page after submitting data to database, then you need to add the rule to a button to clear the values. Other wise you can write those code to clear the values.

    Add following rule to the button after submitting to the Db.

    1. Double click on the button and Select Rules button.
    2. Click on “Add” button
    3. Click on “Add Action” button.
    4. Select “Set a Field Value” from Action field.
    5. Select field xpath from “Field” text box.
    6. Leave “Value” as blank.
    7. Click on ok.
    8. Follow the same steps from  3 to 7 for other fields.

     

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 01-15-2009 11:43 AM In reply to

    Re: how to close views programatically

    Hi,

     I have created a form using different views and controlled by the buttons.  Once the view was selected and saved, I want the same view displayed when the form was opened again.   But when I try to open the form, it always gives me the default view,   is there a way I can do that?  Any helps will be appreciated.

     Vickie

     

  • 01-15-2009 12:35 PM In reply to

    Re: how to close views programatically

    you can make a particular view to get opened by this code

    ViewInfos.SwitchView("Name of your view");

  • 01-16-2009 05:57 AM In reply to

    Re: how to close views programatically

    Hi,

    Before saving the form get the view name by using the following code line.

    thisXDocument.View.Name

    and store this value in a field.

    When you open the form use this value to open the view using the above post code.

     

    Swathip
    www.ggktech.com
  • 01-16-2009 10:28 AM In reply to

    Re: how to close views programatically

    Thanks.  I think this theory will work, but I'm new to InfoPath and never had the experience on JavaScript.  Could you show me where to insert the code (when saved and open) and what exactly the code will be?

     

     

  • 01-16-2009 11:56 PM In reply to

    Re: how to close views programatically

    Hi,

    Add a filed to data source (ex: field1 and its xpath is like /my:myFields/my:field1). Before submitting the form, write the following code.

    XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = XDocument.View.Name;

    Add a switch view event and write the following code.

    function XDocument::OnSwitchView(eventObj)

    {

    var viewName = XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text;

    XDocument.View.SwitchView(viewName);

     }

    Swathip
    www.ggktech.com
  • 01-17-2009 12:41 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: how to close views programatically

    Hello,

    You to follow these steps to insert OnSwitchView in Jscript,

    1. Go to Tools- > Form Options -> Programming.

    2. Select ‘Jscript' in ‘Form template code language' dropdown.

    3. Click on OK button.

    4. Go to Tools -> Programming -> ‘On Switch View Event..'

    You will get script.js file with ‘OnSwitchView' event. In this you have to add the above swathi code.

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