Using templates - Demonstration

Click the City activities title to see what items can be added.

Each of the city activities is specified as a user control.

The same example will be used multiple times opn the next pages to show using different displays.

 
City Activities
XML output

        
Using templates - Description

As previously mentioned, each OffspringsOwner (the Root control, the Choice control and the Branch control) contains a Contents property, which is used to specify this control's children.

Because these children may be rendered more than once (that depends on the Min/MaxOccurs properties and the input xml), the inside of Contents is a template, that is be instantiated on instance control creation.

In order to make code maintenance easier, these templates may be chunked and their common parts may be extracted. This needs some copy-paste manual work.

Let's consider the following example: the form collects data about possible city activities. All of the activities share some data (the address, the opening hours, etc.) but on the other hand all of them have some custom fields.

The schema for this example is in ~/Schemas/Display.xsd file.

For the purpose of this example, the user controls for each of the activities have been extracted. When you look into the activities (they are in ~/Display/UserControls folder), you will see that the common part of all the activities has been extracted into a separate user control. Now if you want to change the common part of all the activities, you have to do it only in one place.