HTMLTaskPane Object

Microsoft Office InfoPath

Show All Show All

HTMLTaskPane Object

HTMLTaskPane

Represents a custom task pane in a Microsoft Office InfoPath 2003 form that is associated with a window. The HTMLTaskPane object provides a number of properties and methods for working with the InfoPath custom task pane, and it provides properties and methods to the TaskPane object as an inherited object.

Remarks

The properties and methods that are available for an InfoPath task pane are determined by the type of task pane that you are working with. If the Type property of the TaskPane object returns 0, the task pane is a custom task pane and the properties and methods that are available are provided by the HTMLTaskPane object. If the Type property returns any other value, the task pane is a built-in task pane and the properties are provided by the TaskPane object directly.

The Type property is based on the XdTaskPaneType enumeration. These enumerated values are also used as arguments to the Item property of the TaskPanes collection for returning a reference to a specified type of task pane.

Note  The properties and methods of the HTMLTaskPane object cannot be called during an OnLoad event because the view is not yet loaded when this event occurs, and task panes are associated with the view.

Using the HTMLTaskPane object

In the following example from the User Interface developer sample form, the Item property of the TaskPanes collection is used to set a global reference to the TaskPane object that represents the custom task pane. The code then calls a scripting function defined in the HTML code of the custom task pane using the HTMLDocument property of the HTMLTaskPane object, which is inherited by the TaskPane object.

    function SetTaskPaneState()
{

   // Ensure View has loaded before trying to access the task pane.
   if (XDocument.View)
   {
      // Get a reference to the custom task pane.  It is always the 0-th
      // task pane in the TaskPanes collection.
      if (gobjTaskPane == null)
         gobjTaskPane = XDocument.View.Window.TaskPanes.Item(0);

      // Ensure that the task pane is completely loaded.
      if (gobjTaskPane.HTMLDocument.readyState == "complete")
      {
         var strTaskPaneViewId = "TP_" + XDocument.View.Name.replace(/\W+/g, "");

         // Call a script function defined in the task pane HTML page.
         gobjTaskPane.HTMLDocument.parentWindow.SelectView(strTaskPaneViewId);
      }
   }
}