Switching Views! - InfoPath Dev
in

InfoPath Dev

Switching Views!

Last post 02-02-2008 08:25 AM by omomani. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 02-02-2008 08:25 AM

    Switching Views!

    Hi all...

    I have a two-view-form!! i got that form published at sharepoint in a given document library. i want to render that form in an ASP application using XmlFormView and to benefit from multi-view feature (switching views)

    that form is viewed in a given view based on the value of a XML-field i created named "ViewName" and in FormEvents_Loading event in VSTA i wrote a code to switch the view based on that value

    Dim MyNav As XPathNavigator

    MyNav = Me.MainDataSource.CreateNavigator()

    Dim ViewNameValue As XPathNavigator = MyNav.SelectSingleNode("/my:myFields/my:viewName", Me.NamespaceManager)

    e.SetDefaultView(ViewNameValue.Value)

    in my ASPX page i have my XmlFormView control to render forms, i got instance from my two-view-form (template) and it is viewed on XmlFormView in its default view ("view 1")... after that i put a button to save that control, i used the following code to save the form back to the document library with "FinalViewTest" name

    webSite.Files.Add("http://sv-testforms/MultiViewsTest/FinalViewTest2.xml", Encoding.Default.GetBytes(xmldoc.InnerXml.ToString), True)

    i used that code coz i dont want to rely on Save button that is already existed in InfoPath plus i can give here the name i want to the form in the doc library....
    In another ASPX page i want to render the same FinalViewTest form but in the second view "view 2" so i need to change the value of ViewName field before rendering the form because switching views code is written in FormEvents_loading event in VSTA and so i cant switch the view unless i changed the ViewName field value before rendering the form.

    i did that by first, get the form as xml from SharePoint. second, change the value of ViewName to "view 2". third, to upload the xmldocument once again to overwrite the original one. last step, then render the form on XmlFormView, now in FormEvents_loading event it will check the value of ViewName field and it will find it "view 2" so it will render the form in the second view!

    i got two questions regarding my case:-
    first one, for my application, the ones who design Forms and publish it to SharePoint are end-users so they have to add the code responsible of switching views before publishing! but end-users are non-technical so how would i minimize their work (i.e. have a simpler procedure to add the ViewName field, and add the code for switching views)?? can i have an add-in button in InfoPath that can do that programmatically without the need of "users to create ViewName field and to go to VSTA and place my code"?? if yes, how can i do that?

    second one, is it quite perfect to get the form and change the value of ViewName field and then upload it back to sharepoint, everytime i need to switch the view???? is there a way to change the ViewName value programmatically without the need of these all steps (i.e. change its value while it is at SharePoint without getting and uploading again)???

     i would appreciate any idea..

    thank you all very much :)

    Osama Momani

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