Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XmlFormView.XmlForm Property

Gets a reference to the main data source of the current form.

Namespace:  Microsoft.Office.InfoPath.Server.Controls
Assembly:  Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)
[BrowsableAttribute(false)]
public XmlForm XmlForm { get; }

Property Value

Type: XmlForm

Use the XmlForm property to get a reference to the form. A limited subset of members can be accessed when using the XmlFormView control. For more information about these members, see the Help included with Microsoft Visual Studio Tools for Applications (VSTA) or Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System.

Properties (Read Only)

  • ReadOnly()

  • New()

  • Uri()

  • XmlLang()

  • Signed()

  • DataSources()

  • MainDataSource()

  • NamespaceManager()

  • FormState()

Methods

  • Submit()

Important noteImportant

Using members other than this subset will result in the error "Calling this property or method from a hosting page is not supported."

Using the XmlForm Property

The XmlForm property can only be accessed during one of the following events:

In the following example, a series of textboxes in the Web page are populated with values from the properties that can be used by accessing the XmlForm property. A value from the main data source of the form is used as the value for TextBox10. This routine is called when code in the form calls the NotifyHost(String) method of the XmlForm object available in the Microsoft.Office.InfoPath namespace, in this case from a button in the form.

[Visual Basic]

The following example requires the following three Imports statements:

Imports System.Xml
Imports System.Xml.XPath
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
    Dim xNavMain As XPathNavigator
    Dim xNameSpace As XmlNamespaceManager
    Try
        TextBox2.Text = XmlFormView1.XmlForm.[New].ToString()
        TextBox3.Text = XmlFormView1.XmlForm.ReadOnly.ToString()
        TextBox4.Text = XmlFormView1.XmlForm.MainDataSource.ReadOnly.ToString()
        TextBox5.Text = XmlFormView1.XmlForm.ToString()
        TextBox6.Text = XmlFormView1.XmlForm.XmlLang.ToString()
        TextBox7.Text = XmlFormView1.XmlForm.Signed.ToString()
        TextBox8.Text = XmlFormView1.XmlForm.FormState.Count.ToString()
        TextBox9.Text = XmlFormView1.XmlForm.DataSources.Count.ToString()
        xNavMain = XmlFormView1.XmlForm.MainDataSource.CreateNavigator()
        xNameSpace = New XmlNamespaceManager(New NameTable())
        xNameSpace.AddNamespace("my", XmlFormView1.XmlForm.NamespaceManager._
        LookupNamespace("my").ToString())
        TextBox10.Text = xNavMain.SelectSingleNode("/my:myFields/my:field2", xNameSpace).ToString()
    Catch ex As Exception
        TextBox11.Text = ex.Message.ToString()
    End Try
End Sub

[C#]

The following example requires the following three using statements:

using System.Xml;
using System.Xml.XPath;
using Microsoft.Office.InfoPath.Server.Controls;
protected void XmlFormView1_NotifyHost(object sender, NotifyHostEventArgs e)
{
    try
    {
        TextBox2.Text = XmlFormView1.XmlForm.New.ToString();
        TextBox3.Text = XmlFormView1.XmlForm.ReadOnly.ToString();
        TextBox4.Text = XmlFormView1.XmlForm.MainDataSource.ReadOnly.ToString();
        TextBox5.Text = XmlFormView1.XmlForm.ToString();
        TextBox6.Text = XmlFormView1.XmlForm.XmlLang.ToString();
        TextBox7.Text = XmlFormView1.XmlForm.Signed.ToString();
        TextBox8.Text = XmlFormView1.XmlForm.FormState.Count.ToString();
        TextBox9.Text = XmlFormView1.XmlForm.DataSources.Count.ToString();
        XPathNavigator xNavMain = XmlFormView1.XmlForm.MainDataSource.CreateNavigator();
        XmlNamespaceManager xNameSpace = new XmlNamespaceManager(new NameTable());
        xNameSpace.AddNamespace("my", XmlFormView1.XmlForm.NamespaceManager.LookupNamespace("my").ToString());
        TextBox10.Text = xNavMain.SelectSingleNode("/my:myFields/my:field2", xNameSpace).ToString();
    }
    catch (Exception ex)
    {
        TextBox11.Text = ex.Message.ToString();
    }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.