Using the XmlFormView Control

The XmlFormView is a common way to display Office InfoPath 2007 browser forms on a custom ASPX page. Microsoft published a great technical article a while back about how to use the XmlFormView control to host the InfoPath editing environment, and we use it frequently in our InfoPath Forms Services solutions.

One thing to keep in mind though, which the article does mention, is that the InfoPath form template that is to be displayed in the XmlFormView control must reside in the same site collection as the custom ASPX page. In other words, if you have a Web application with a site URL of http://moss.litwareinc.com and your form template has been admin-deployed or published directly to a Web application with a site URL of http://anytown.litwareinc.com, then that form cannot be hosted on a Web page within the http://moss.litwareinc.com site collection.

Continuing with this example, the solution to the problem is quite simple if the form template was admin-deployed to the http://anytown.litwareinc.com site collection. There are no restrictions imposed by InfoPath Forms Services about the number of site collections to which you can activate your form template. So, assuming data connections in your form template have been managed correctly (a topic for another day), then you can simply activate the form template to the http://moss.litwareinc.com site collection. Then, with the XmlFormView control selected in your custom ASPX page in Visual Studio, you can set the XsnLocation property to the relative location of the form template within the site collection.



Print | posted on Wednesday, February 20, 2008 11:47 AM

Feedback

# re: Using the XmlFormView Control

Left by Chris at 7/10/2008 12:07 AM
Gravatar That appears to work fine to create the form and submit it (in your example from the http://moss.litwareinc.com site collection to http://anytown.litwareinc.com.
However, are you therafter able to view the form instance from the http://moss.litwareinc.com site collection? So I now have to set the XmlLocation property on my custom aspx page hosting the xmlformview control in the context of the http://moss.litwareinc.com site collection but targeting the http://anytown.litwareinc.com. I would love to know if there is a way to do that.

# re: Using the XmlFormView Control

Left by David Gerhardt at 7/10/2008 9:25 AM
Gravatar Hi, Chris.

With the XmlFormView control, the same principle that applies to form templates also applies to form files: the form file must be in the same site collection as the ASPX page. You can make a relative reference to a form file in the same site collection by modifying the XmlLocation property value accordingly (for example, "/permits/12345.xml").

I hope this helps...

Regards,
David

Your comment:





 
Please add 3 and 4 and type the answer here:

Copyright © David Gerhardt

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski