Databases Reference
In-Depth Information
The
Description
property of the MetaColumn class returns the description specified in
code by applying the
DescriptionAttribute
to the entity property. The built-in field
templates Dynamic Data provides do not currently utilize this property. However, you can
easily modify them and use this property to generate a tooltip for the data controls in
field templates.
Formatting Options
The last remaining data annotation properties worth mentioning are the ones related to
formatting options that can be specified by applying the
DisplayFormatAttribute
to the
entity property. These properties are used by the
DynamicControl
and
DynamicField
controls to implement flexible and consistent formatting of field values.
public string DataFormatString { get; }
The
DataFormatString
property returns a string that contains a .NET format string, such
as
“{0:C}”
, that will be used to convert field value to a string by calling the
Format
method of the
String
class. Although including the parameter number
0
might seem
unnecessary, knowing that there is only one field value to format, it is required for the
format string to work properly.
public bool ApplyFormatInEditMode { get; }
The
ApplyFormatInEditMode
property determines whether Dynamic Data will use the
DataFormatString
not only in Read-only mode and on List and Details pages, but also in
Edit mode as well.
public string NullDisplayText { get; }
The
NullDisplayText
property specifies the text Dynamic Data will display when the field
value is null.
public bool ConvertEmptyStringToNull { get; }
The
ConvertEmptyStringToNull
property determines whether
NullDisplayText
will be
used for empty strings as well.
public bool HtmlEncode { get; }
The
HtmlEncode
property determines whether any special characters that might be a part
of the field value will be encoded using HTML escape sequences. This property is true by
default, making the dynamically generated pages immune against HTML injection attacks.
You should only consider changing it when your application allows users to enter format -
ted text in HTML form and performs thorough cleansing of the values entered by users to
remove dangerous HTML tags, such as
<script>
, before saving them in the database.