Export (0) Print
Expand All

XmlFormView Class

The main ASP.NET control used to show InfoPath forms in a browser.

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      System.Web.UI.WebControls.Panel
        System.Web.UI.WebControls.WebParts.Part
          System.Web.UI.WebControls.WebParts.WebPart
            Microsoft.Office.InfoPath.Server.Controls.XmlFormView

Namespace:  Microsoft.Office.InfoPath.Server.Controls
Assembly:  Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class XmlFormView : WebPart, 
	INamingContainer

The XmlFormView object and its associated members are used to display InfoPath forms in a Web browser. No additional components are necessary on the desktop computer except a Web browser in order to open and fill out a form based on a browser-enabled form template.

InfoPath Forms Services uses the XmlFormView control to display forms based on form templates designed in Microsoft Office InfoPath 2007 so that they are browser-compatible. Developers can also use the XmlFormView control to show InfoPath forms in custom Web pages. This requires a server with InfoPath Forms Services, either as part of Microsoft Office SharePoint Server 2007 with a client access license for InfoPath Forms Services, or Microsoft Office Forms Server 2007. For more information on how to develop custom Web pages with the XmlFormView control, see Hosting the InfoPath 2007 Form Editing Environment in a Custom Web Form.

In the following example, the XmlFormView control, XmlFormView1, is hosted in a custom Web page and contains a browser-enabled form template located on the same site. The NotifyHost event of the XmlFormView control is used to populate a control, TextBox1, in the custom Web page.

[Visual Basic]

Imports Microsoft.Office.InfoPath.Server.Controls
Protected Sub XmlFormView1_NotifyHost(ByVal sender As Object, ByVal e As Microsoft.Office.InfoPath.Server.Controls.NotifyHostEventArgs) Handles XmlFormView1.NotifyHost
    TextBox1.Text = e.Notification.ToString()
End Sub

The form code necessary to send a value from the main data source in the form, my:field2, to the hosting Web page uses the NotifyHost(String) method of the XmlForm object available in the Microsoft.Office.InfoPath namespace, in this case from a button in the form.

Public Sub CTRL3_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
    Dim myNav As XPathNavigator = Me.MainDataSource.CreateNavigator()
    Me.NotifyHost(myNav.SelectSingleNode("/my:myFields/my:field2", Me.NamespaceManager).ToString())
End Sub

[C#]

using Microsoft.Office.InfoPath.Server.Controls
protected void XmlFormView1_NotifyHost(object sender, NotifyHostEventArgs e)
{
    TextBox1.Text = e.Notification.ToString();
}

The form code necessary to send a value from the main data source in the form, my:field2, to the hosting Web page uses the NotifyHost(String) method of the XmlForm object available in the Microsoft.Office.InfoPath namespace, in this case from a button in the form.

public void CTRL3_5_Clicked(object sender, ClickedEventArgs e)
{
    XPathNavigator myNav = this.MainDataSource.CreateNavigator();
    this.NotifyHost(myNav.SelectSingleNode("/my:myFields/my:field2", this.NamespaceManager).ToString());
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft