Improving FieldTemplates
Back
The FieldTemplate is a central element of ASP.NET Dynamic Data. It supplies the
user interface for a single data type and mode (readonly, edit, or insert). DES
Dynamic Data starts its enhancements by providing a richer base class for FieldTemplates
(DESFieldTemplateUserControl) that lightens the load on the code needed in the actual
FieldTemplates. Here are other enhancements:
- Replacements for all existing FieldTemplates, to support the DES Validation Framework,
utilize DES's extended FieldTemplate base classes, and to introduce new properties that
make the FieldTemplates more flexible.
- FieldTemplates for each of its datatype oriented textboxes: Integer, Decimal, Currency,
Percent, Date, Time, Duration, MonthYear, and Anniversary. There are specialized
FieldTemplates too: Calendar_Edit.ascx uses the DES Calendar control for Dates;
Measurement for integers and decimals that reflect a measurement; and for Telerik
RadControls users, templates built upon many of their data entry controls. See below.
- FieldTemplates can be customized without modification through the Customizer control,
which you add to your web form. The Customizer control establishes page-level rules
for various types of fields, such as showing the currency symbol on all currency fields.
The Customizer control is also where you define the error messages for validators,
to override the ValidationAttributes, which define error messages globallly.
- You will not need to add any Validators to your FieldTemplates. Instead, you add
the ColumnValidatorManager control which uses your business logic to create your validators.
As a result, you are assured that your FieldTemplates always have the correct validation,
even if the business logic later changes.
- Use the ICustomizeFieldTemplate interface
to change the controls generated by the FieldTemplate at runtime. For example, to make modifications that vary based on the current data.
- Uses a new FieldTemplateFactory class (DESFieldTemplateFactory) to lookup FieldTemplates
according to rules you define. It provides aliases to map the requested template
name to a new name and the ability to look for FieldTemplates in several folders.
The rules are defined in an xml file.
- When creating your own FieldTemplates, start with rich base classes where you only need to supply the
actual web controls. All of the logic for data binding is handled. So is applying settings from the Customizer control. This greatly
simplifies creating new FieldTemplates and eliminates bugs.
- The code behind files are eliminated. While code behind has a purpose, when you need
to duplicate web forms, they can cause problems, especially with regard to namespaces.
Many times you end up with two web forms that have the same class and namespace,
causing compilation errors. Since DES moves most of the code into its base classes,
the remaining code on a FieldTemplate is so small, that the benefits of single file
outweigh the benefits of code behind.
You can still use code behind files in FieldTemplates that you create.
FieldTemplates provided with DES Dynamic Data
DES Dynamic Data has replacements for every FieldTemplate supplied with ASP.NET
Dynamic Data. It does this because it works from an enhanced version of the FieldTemplateUserControl
class. Don't worry, installation will copy your existing templates to a subfolder
of the FieldTemplates folder.
DES Dynamic Data has increased the available data types too. So there are many new
FieldTemplates offered.
Template name
|
DataControl type
|
DataTypes
|
Notes
|
Anniversary.ascx
|
Label
|
DateTime
|
|
Anniversary_Edit.ascx
|
AnniversaryTextBox
|
DateTime
|
|
Boolean.ascx
|
Image
|
Boolean
|
Displays different images
|
BooleanLabel.ascx
|
Label
|
Boolean
|
|
BooleanCheckBox.ascx
|
Checkbox
|
Boolean
|
Checkbox is disabled
|
Boolean_Edit.ascx
|
Checkbox
|
Boolean
|
|
Calendar_Edit.ascx
|
Calendar (DES)
|
DateTime
|
Use UIHint(“Calendar”) on DateTime
|
Children.ascx
|
Hyperlink
|
|
Goes to the related table
|
Currency.ascx
|
Label
|
Double, Decimal
|
|
Currency_Edit.ascx
|
CurrencyTextBox
|
Double, Decimal
|
|
Date.ascx
|
Label
|
DateTime
|
|
Date_Edit.ascx
|
DateTextBox
|
DateTime
|
|
DateTime.ascx
|
Label
|
DateTime
|
|
DateTime_Edit.ascx
|
DateTextBox and TimeOfDayTextBox
|
DateTime
|
|
DbImage.ascx
|
Image
|
Binary (image)
|
Display an image
|
DbImage_Edit.ascx
|
Image
|
Binary (image)
|
Display and upload an image
|
Decimal.ascx
|
Label
|
Double, Decimal
|
|
Decimal_Edit.ascx
|
DecimalTextBox
|
Double, Decimal
|
|
Duration.ascx
|
Label
|
DateTime, Double, Decimal, Integer
|
|
Duration_Edit.ascx
|
DurationTextBox
|
DateTime, Double, Decimal, Integer
|
|
Enumerated.ascx
|
Label
|
Integer, String
|
Optionally maps the raw value to different text.
|
Enumerated_Edit.ascx
|
DropDownList
|
Integer, String
|
Optionally maps the raw value to different text.
|
ForeignKey.ascx
|
HyperLink
|
|
Links to a PageTemplate showing the details of a record.
|
ForeignKey_Edit.ascx
|
DropDownList
|
|
|
Integer.ascx
|
Label
|
Integer
|
|
Integer_Edit.ascx
|
IntegerTextBox
|
Integer
|
|
Measurement.ascx
|
Label
|
Integer, Double, Decimal
|
Specialized number that includes a label
|
Measurement_Edit.ascx
|
IntegerTextBox or DecimalTextBox
|
Integer, Double, Decimal
|
Specialized number that includes a label
|
MonthYear.ascx
|
Label
|
DateTime
|
|
MonthYear_Edit.ascx
|
MonthYearTextBox
|
DateTime
|
|
MultilineText_Edit.ascx
|
TextBox (TextMode=Multiline)
|
String
|
Offers a TextCounter control.
|
Password.ascx
|
Label
|
String
|
Shows “*****” instead of the password
|
Password_Edit.ascx
|
FilteredTextBox (TextMode=Password)
|
String
|
|
Percent.ascx
|
Label
|
Double, Decimal
|
|
Percent_Edit.ascx
|
PercentTextBox
|
Double, Decimal
|
|
Text.ascx
|
Label
|
String
|
Also used by multiline text in readonly mode.
|
Text_Edit.ascx
|
FilteredTextBox
|
String
|
Supports characterset filtering
|
Time.ascx
|
Label
|
DateTime
|
|
Time_Edit.ascx
|
TimeOfDayTextBox
|
DateTime
|
|
Url.ascx
|
Hyperlink
|
String
|
Provide a hyperlink for the URL
|
Url_Edit.ascx
|
TextBox
|
String
|
|
UrlAsImage.ascx
|
Image
|
String
|
Display an image associated with the URL
|
UrlAsImage_Edit.ascx
|
Image and TextBox
|
String
|
|
If you use Telerik RadControls for
ASP.NET AJAX, it also provides FieldTemplates that merge the RadControls
data entry controls with the DES Validation Framework as shown here:
Template name
|
DataControl type
|
DataTypes
|
Notes
|
Currency_Edit.ascx
|
RadNumericTextBox
|
Decimal, Double
|
|
Date_Edit.ascx
|
RadDatePicker
|
DateTime
|
|
DateTime_Edit.ascx
|
RadDateTimePicker
|
DateTime
|
|
Decimal_Edit.ascx
|
RadNumericTextBox
|
Decimal, Double
|
|
Enumerated_Edit.ascx
|
RadCombobox
|
Integer, String
|
|
ForeignKey_Edit.ascx
|
RadCombox
|
|
|
Html_Edit.ascx
|
RadEditor
|
String
|
Use DataTypeAttribute with DataType=Html.
|
Integer_Edit.ascx
|
RadNumericTextBox
|
Integer
|
|
Measurement_Edit.ascx
|
RadNumericTextBox
|
Integer, Decimal, or Double
|
|
MultilineText_Edit.ascx
|
RadTextBox (TextMode=Multline)
|
String
|
|
Percent_Edit.ascx
|
RadNumericTextBox
|
Decimal or Double
|
|
Text_Edit.ascx
|
RadTextBox
|
String
|
|
Time_Edit.ascx
|
RadTimePicker
|
DateTime
|
|
Back
|