Export (0) Print
Expand All

HtmlTaskPane.HtmlWindow property

Gets a reference to the MSHTML IHTMLWindow2 interface for working with the HTML document of a custom task pane.

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

public abstract Object HtmlWindow { get; }

Property value

Type: System.Object
An IHTMLWindow2 object associated with HTML file of the custom task pane.

ExceptionCondition
SecurityException

The form template is not configured for Full Trust using the Security and Trust category of the Form Options dialog box.

Using the HtmlWindow property, you can call scripting functions contained in the HTML code of the task pane from the primary form code, manipulate the HTML code of the task pane, and work with any of the properties and methods that the IHTMLWindow2 interface provides.

NoteNote

The HtmlWindow property provides the same functionality as the HtmlDocument property, but it is only available when using fully trusted forms. If the form is not fully trusted, you can use the HtmlDocument property instead.

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.

In the following example, the HtmlWindow property of the HtmlTaskPane class is used to set a reference to the IHTMLWindow2 object of the custom task pane of a fully trusted form. Then the code calls the TaskPaneSwitchView custom function that is defined in the HTML code of the custom task pane.

   // Get a reference to the custom task pane. It is always index [0]
   // in the TaskPanes collection.
   HtmlTaskPane custom = (Microsoft.Office.InfoPath.HtmlTaskPane)
      this.CurrentView.Window.TaskPanes[0];

   // Get a reference to the parent window of the task pane.
   IHTMLWindow2 window = (IHTMLWindow2)custom.HtmlWindow;

   // Call into script through CLR late binding mechanism.
   window.GetType().InvokeMember(
      "TaskPaneSwitchView",      // late bound method name.
      System.Reflection.BindingFlags.InvokeMethod | // binding flags
      System.Reflection.BindingFlags.DeclaredOnly |
      System.Reflection.BindingFlags.Public |
      System.Reflection.BindingFlags.Instance,
      null,     // binder object
      window,   // target object
      null);   // method arguments
Show:
© 2014 Microsoft