InfoPath Form Templates and Form Template Parts

When creating a new form in InfoPath, you can create a new template that build out a new packaged .XSN file, or you can build on one of the newer features provided with InfoPath 2007 called a Form Template Part, which instead creates an .XTP file.

Template parts can be loosely compared to User Controls within the Visual Studio IDE. When using template parts, the InfoPath templates that contain controls, datasources, formatting, validation, formatting, rules, and calculations can be reused over and over again without having to keep performing the same redundant tasks. Using Form Template Parts reduces overall code bloat because of reference establishment and increases time to production since the amount of custom development for the form is overall decreased. Template Parts use Object Oriented development principles, whereby an object can be developed, and then instantiated by users, who are unaware of the backend plumbing that provides the control functionality.

For example, to call a new Form Template Part that houses the relevant TextBox ID control, under the New Design option instead of creating a new InfoPath form template select create a new Form Template Part (see Figure 14-5 ).

Figure 14-5

Once the Template Part design surface is open, drag the Text Box control unto it and change the field name property of the Text Box control to ID (see Figure 14-8)

Figure 14-8

You can optionally add other InfoPath controls and their related attributes to the Form Template Part design surface in the same way that InfoPath controls are added. Afterwards, select the Save as option so the Form Template Part is saved to a local .XTP file (See Figure 14-6), which will make it available to users under the controls section within the InfoPath Designer once they successfully import it (See Figure 14-7) using the Add or Remove Custom Controls dialog.

Figure 14-6

Figure 14-7

The control can then be dragged onto the IndoPath design surface from the Custom Controls Toolbox under the Controls Toolpane.(See Figure 14-9)

Figure 14-9