Creating Custom Task Panes


Another easy way to extend InfoPath functionality is to create your own custom task pane. You can create task panes by using HTML and the web development tool of your choice. Custom task panes can be used to display help text or instructions for filling out a form, to display additional information the form user may need (for example, lookup tables), and even to interact with the form data. The following sections look at how to create a simple HTML page and display it in a custom task pane.

To start, you need to create your HTML page using the editor of your choice. The example in this section is a page of instructions on how to fill out a particular form. When the user fills out the form, they can view these instructions in the task pane when required. Once you have developed a web page to use in a custom task pane, preview it in Internet Explorer to make sure all the content looks right. Note the name and location of the HTML file.

Next, in your form’s design, select Tools | Form Options to open the Form Options dialog box, and then click the Advanced tab, shown in Figure 10-3.

click to expand
Figure 10-3: Advanced form options

Click the Enable Custom Task Pane check box and then enter a name for your pane. In this example, the pane is called Form Instructions. For the task pane location, type the location of your HTML file, including the full path.

Alternatively, you can add the HTML page that you created as a resource so that you can select it from the Task Pane Location drop-down list. Resources within an InfoPath form are additional files that are added to the form template file and can include script files, images, HTML pages, and so forth. To add your HTML page as a resource, click the Resource Manager button and browse to select the file. In addition to the HTML file, you also need to select any related files (graphics, style sheets, and so on).

Note

When you add a resource file to a form, it is embedded into the form. If you need to edit a resource later, you need to export it from the Resource Manager to get the file back again.

Once you have added your file to the Resource Manager, it should appear in the Task Pane Location drop-down list and you can select it from the list. Now, click OK to close the Form Options dialog box and return to your form’s design. Whenever you preview your form, your new custom task pane will be available from the drop-down list at the top of the task pane, as shown in Figure 10-4.

click to expand
Figure 10-4: A custom task pane

In addition to displaying simple HTML pages, you can interact with your InfoPath form through the extension property of the task pane. To use this property within your task pane page, you need to declare your XDocument object first and then you can use the extension property to access functions and variables within your script. In the following example, you could have a link in your HTML page that called the SumAllOrders function within your InfoPath script:

myTaskPane = window.external.XDocument;
myTaskPane.Extension.SumAllOrders();

Note

For more information on accessing functions and variables within your InfoPath scripts, open the InfoPath Developer’s Guide and search for the keyword “extension.”




How to Do Everything with Microsoft Office InfoPath 2003
How to Do Everything with Microsoft Office InfoPath 2003 (How to Do Everything)
ISBN: 0072231270
EAN: 2147483647
Year: 2006
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net