Show All

# Custom task panes in the User Interface developer sample form

The User Interface developer sample form implements a custom task pane that is used to switch views and perform other general-purpose operations, such as sorting the list of CDs. Custom task panes are .html files that are displayed in the Microsoft Office InfoPath 2003 task pane as a user fills out a form. There can be only one custom task pane associated with a form.

To create a custom task pane, you must first create an .html file by using an HTML editor such as Microsoft FrontPage. You associate this .html file with a form by using the Advanced tab in the Form Options dialog box that is available on the Tools menu in design mode. The Advanced tab allows you to add the .html file and any other supporting files, such as a cascading style sheet (.css file), using the Resource Manager. (The Resource Manager can also be accessed by clicking Resource Manager on the Tools menu in design mode.) After the .html file has been added as a resource, you can select the Enable custom task pane check box and set the name and location of your custom task pane.

Note You must add the .html file to the form using the Resource Manager before you can make the file a custom task pane.

When you add a custom task pane to a form, InfoPath creates entries in the form definition (.xsf) file using the taskpane element. The caption attribute of the taskpane element is used to store the name of the custom task pane, while the href attribute is used to store the .html file name. The following is a section from the .xsf file of the User Interface developer sample form that contains the taskpane element:

    <xsf:taskpane
       caption="Custom Task Pane"
       href="taskpane.htm">
    </xsf:taskpane>

In addition to using standard HTML markup, you can also use scripting code within the task pane that calls the InfoPath object model. In the User Interface developer sample form, the Extension property of the XDocument object is used to gain access to the business logic functions contained in the form's primary script file.

The following is a section from the .html file used as the custom task pane in the User Interface developer sample form. The call to the InfoPath object model's Extension property is used in the onClick event for the Sort CDs hyperlink. When the user clicks this link, the Sort function within the form's primary script file is called. The Sort function then takes the source XML document for the form and sorts the collection of CDs alphabetically according to artist and track.

    <div class="action">
       <a href=""
          onClick="gobjXDocument.Extension.Sort();return false;">
          Sort CDs by artist/title</a>
    </div>

Note To view the business logic functions for the User Interface developer sample form, you can open Microsoft Script Editor (MSE) in InfoPath design mode by clicking the Tools menu, pointing to Script, and clicking Microsoft Script Editor, or by pressing ALT+SHIFT+F11.

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp