Connect.Collaborate.SharePoint

How to enable and use the SharePoint XmlFormView Web Part

One way to host a browser enabled form in a web part is to use the Page View web part as in this demo http://www.wssdemo.com/Pages/form.aspx.

Another option is to enable the web part that ships with the product by adding the following to the web.config file

<SafeControl Assembly="Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.Office.InfoPath.Server.Controls" TypeName="XmlFormView" Safe="True"/>

Why isn't this available out of the box? Because it doesn't quite work properly. If you did add the web part to the gallery, you wouldn't be able to set the properties for the web part because, just because (the reason why it isn't added to the gallery).

The solution to setting the web part properties is to create your own .webpart file on your client PC and import it onto the web part page through the web UI.

Your .webpart file should look like this

<?xml version="1.0" encoding="utf-8"?>
<webParts>
 <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
  <metaData>
   <type name="Microsoft.Office.InfoPath.Server.Controls.XmlFormView, Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
   <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
  </metaData>
  <data>
   <properties>
    <property name="Title" type="string">XmlFormView</property>
    <property name="XmlLocation" type="string">~sitecollection/Form2/ian.xml</property>
   </properties>
  </data>
 </webPart>
</webParts>

The list of properties for the web part can be found here
http://msdn2.microsoft.com/en-us/library/microsoft.office.infopath.server.controls.xmlformview_properties.aspx

You will need at least the XmlLocation or XsnLocation properties depending on whether you want to display an existing form submission or a blank form.

Demo page http://www.wssdemo.com/Pages/Form-Web-Part.aspx

Posted by Ian Morrish on Saturday, 1 Mar 2008 01:58 | 0 Comments
SharePoint

Links to this post

Name

Url

Email

Comments

CAPTCHA Image Validation