XmlForm.Extension Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets an Object for accessing the functions and global variables contained in a form's primary form code file using System.Reflection.
public:
abstract property System::Object ^ Extension { System::Object ^ get(); };
public abstract object Extension { get; }
member this.Extension : obj
Public MustOverride ReadOnly Property Extension As Object
Property Value
An Object for accessing the functions and global variables contained in a form's primary form code file using System.Reflection.
Examples
In the following code example, the Extension property is used to return a System.Object to invoke the custom method called MyMethod
.
object extObj = this.Extension;
extObj.GetType().InvokeMember("MyMethod",
BindingFlags.InvokeMethod |
BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.Instance, null, extObj, null);
Dim extObj As Object extObj = Me.Extension
extObj.GetType().InvokeMember("MyMethod", _
BindingFlags.InvokeMethod Or _
BindingFlags.DeclaredOnly Or _
BindingFlags.Public Or _
BindingFlags.Instance, Nothing, extObj, Nothing)
In the following code example, a method called myCustomMethod
of the InfoPath form code project class can be accessed from the custom task pane using the Extension property.
// Custom method added to the form code project.
public string myCustomMethod()
{
return "Method value";
}
' Custom method added to the form code project.
Function myCustomMethod() As String
myCustomMethod = "Method value"
End Function
To access myCustomMethod
from script in the custom task pane, use the DHTML external property of the DHTML window object.
objXmlForm = window.external.XmlForm;
myString = objXmlForm.Extension.myCustomMethod();
Dim objXmlForm
Dim myString
Set objXmlForm = window.external.XmlForm
myString = objXmlForm.Extension.myCustomMethod()
Remarks
The System.Object returned by the Extension property facilitates using the functions and global variables implemented in an InfoPath form code file. Usually, it is used from a custom task pane, from a custom dialog box, or in the XSL Transform (XSLT) of a view where direct access to the functions and variables may be needed.
To use the System.Object within a custom task pane, you must first set a reference to the XmlForm object by using the Dynamic HTML (DHTML) external property of the DHTML window object, as shown in this example.
objXmlForm = window.external.XmlForm;
This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.
This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.