SUMMARY
The default user interface templates and the templates selection method, used by
smartDBforms.NET, are stored
in the ASP.NET <WebSiteRoot>\smartDBtemplates\TemplatesStorage.ascx
file. You can modify the behaviour and outlook of smartDBforms.NET by modifying
this file.
MORE INFORMATION
Modifying user interface templates
Open the <WebSiteRoot>\smartDBtemplates\TemplatesStorage.ascx file in design
mode. Each TemplateHolder control represents one user interface template. The ID
of the TemplateHolder is used to identify it in the template selection method.
TemplateHolder contains three templates - Edit Template, Read-only Template and
Label Template. Label Template defines the user interface for the label part
of the user interface. Label Template can be left empty and a global Label Template
can be used by setting the LabelTemplateID property in the smart-tag panel.
Edit Template defines the user interface used for editing an existing or inserting
a new data in the database table. The Read-only template is used to display the
data. In some cases read-only template can be used in insert and edit mode. For
example when the edited field is primary key then it is non-editable in edit mode.
The layout of the label part and the data part(edit or read-only template) is specified
by a LayoutHolder control. The TemplateHolder control has a property named LayoutTemplateID,
which specifies the layout to use when rendering the label and the data parts.
The templates in the TemplateHolder use two-way databinding. The object and its
properties, that is available for during databiding are described in the DataBindItem Class online documentation.
Modifying the template selection method
The template selection method is defined in the code section of the TemplatesStorage.ascx
file. Open the file in Source view and search for the SelectTemplateID method. It
has only one input parameter of type DataBindItem. The DataBindItem provides value
and type information for the current database field. The return value is the ID
of the TemplateHolder which should be used to generate the user interface for this
database field.
IMPORTANT: By default the SelectTemplateID method in TemplatesStorage.ascx file
is not used. Instead of it a precompiled version of the method is used. This is
in order to support design time automatic template selection. In order to start
using the inline method you should remove the TemplateSelectorType property of the
TemplatesControlCenter control at the top of the file.
After you have finished the modifications of the method you can copy it to a Class
Library project and copy the compiled .dll to the bin folder of the website.
The method should be placed in a class that inherits from Adillis.SmartDBForms.ITemplateSelector.
In this way the template selection method will be available in the Visual Studio
Designer. You also have to set the TemplateSelectorType property of the TemplatesControlCenter
control to reference the class.
For more information on template selection see
Template Selection in the online documentation.
Starting from scratch
You can also create a new template set that will replace the default one. See Creating
New Template Set in the online documentation. In order to set the new template
set as the active one open it in Design mode, open the smart-tag panel of the TemplatesControlCenter
control and select the Activate method. This will set the current template set as
the active one in the Web.config file.