switchView won't switch - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

switchView won't switch

Last post 04-01-2015 12:48 AM by umashiva. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 07-20-2006 02:24 AM

    switchView won't switch

    Hi,

    stupid question, but why doesn't this work? The onload-Event is executed, but the view doesn't switch.

    [InfoPathEventHandler(EventType=InfoPathEventType.OnLoad)]
    public void OnLoad(DocReturnEvent e)
    {
    thisXDocument.UI.Alert("onload works!!!");
    // Write your code here.
    if(!thisXDocument.IsNew)
    {
    thisXDocument.View.SwitchView("ReadOnly");
    }
    }

    Thanks in advance.

    Regards,

    Andi
  • 07-20-2006 02:40 AM In reply to

    • Stavi
    • Top 100 Contributor
    • Joined on 12-13-2005
    • Posts 95

    Re: switchView won't switch

    That clever bloke Greg Collins has done a "how to" on switching views when form is opening

    http://www.infopathdev.com/howto/tutorials/default.aspx?i=b5613773df374e42a0dddc22acb21d8e

    I'm not that great at code so i'll let you read it yourself
  • 07-20-2006 02:42 AM In reply to

    Re: switchView won't switch

    Thanks :)
  • 07-21-2006 02:49 PM In reply to

    Re: switchView won't switch

    I will have to agree that Greg Collins is quite a clever bloke!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-21-2006 04:02 PM In reply to

    Re: switchView won't switch

    <blush/>
  • 07-24-2006 09:02 AM In reply to

    Re: switchView won't switch

    This does work wonders in InfoPath 2003, but does not work with Infopath 2007 due to the object model change.
    Does anyone, including Greg, how to set the feault view in the onload event using InfoPath 2007?
    Thank you
  • 07-25-2006 11:13 AM In reply to

    Re: switchView won't switch

    In IP07 (C#) you would use:

    ViewInfos.SwitchView("View Name"); // normal view switch
    e.SetDefaultView("View Name"); // set the default view during the Loading event

    You might be tempted to do the following, but it's not what you might think:

    ViewInfos.Initial = ViewInfos["View Name"]; // Set the default initial view in the XML PI to be opened the next time the form is loaded.
  • 01-23-2008 07:57 AM In reply to

    Re: switchView won't switch

    hello all, hello Mr. Greg :)

    i have a web page with a XmlFormView control rendering a form published in sharepoint!!!

    my XmlFormControl name is NewFormXmlFormView, how can i switch the view of my form before rendering in the page.

    on my ASPX page Load event what should i write to switch the view???

    i tried NewFormXmlFormView.SetDefaultView but SetDefaultView was not a part of NewFormXmlFormView!!!

    please, any ideas??? i will be grateful

    thanks,

    Osama

  • 01-26-2008 04:13 PM In reply to

    Re: switchView won't switch

    Hi

    This can be fairly simply achieved by making it conditional on a field value as to which view to open (as long as you are in InfoPath). So if WORKFLOW field = 1 then switch to view 1 if 2 to view 2 and so on.

     

    I hope this helps 

    Adam Harding
    Wales
    UK
  • 01-27-2008 12:18 AM In reply to

    Re: switchView won't switch

    ok... thank you adamrhaarding for your reply?

    but i have a question and i wonder if anyone can help in that!!

    i want to apply the way you provided me (i.e. i will have a field named VIEW, its value will be the name of the view i want to render). after that in OnLoad event in infopath form i will make the form loaded in the view specified in VIEW field, and it will work) but my question is how can i change the value of VIEW fiedl????

    i can change the value each time i save\submit the form to sharepoint, and in the next time the form to be rendered it will be rendered in the view i specified while saving (i.e. the form is rendered in VIEW 1, i have filled it out, changed the value of VIEW filed to VIEW 2, and then submit the form to share point) next time to render the form it will be rendered in VIEW 2, right?? ok i got this, but here i have a problem, i need to specify the view to be opened with in my ASPX Page Load event.. do u have a way to change the value of VIEW field in Page load event in ASP.net???? i appreciate any idea :)

     

    thanks..

    Osama Momani. 

  • 06-17-2009 10:43 AM In reply to

    Re: switchView won't switch

    Hi there

    Would you mind showing me a piece of code for it. I look forward to hearing from you. Many thanks

    Regards

    Rodolfo 

     

    Filed under:
  • 01-13-2010 02:28 AM In reply to

    • stukkend
    • Not Ranked
    • Joined on 01-13-2010
    • South Africa
    • Posts 7

    Re: switchView won't switch

     Hi there,

     I know this might be extremely obvious to most of you, but for me as a newcomer to InfoPath Development i thought I'd just add the following, just as a matter of being pedantic about getting things right:

    This code above works well in the Load event ( e.SetDefaultView("viewName") ), but if you are going to set the default view based on certain values, don't forget to set the "main" default view for the form somewhere at the top of your code.

    I dont know how better to explain this, so let me use an example:

    //All your initialization happens here...

    //Now we need to set the "main" default view...

    e.SetDefaultView("view1");

    //you have the condition for when the default view should change

    if (somevalue)
    e.SetDefaultView("view2");

    Remember that should you just set the default view without initializing it, the next time the form is opened, it will open "view2", which was a bit unexpected for a beginner like me.

    Thanks for this great site!

    life happens...
  • 04-01-2015 12:48 AM In reply to

    Re: switchView won't switch

    Hi Greg, I have InfoPath 2010 form, which has many views... each view has many controls.. After submission of the form, If user change any value inside any views, i need to send an email notification saying that the value is changed... Is there any way to achieve the above requirement? Thanks..
Page 1 of 1 (13 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.