Databases Reference
In-Depth Information
In field templates, this annotation is available via the
Description
property of the
MetaColumn
class. Field templates typically use it in
Load
event handlers to set the
ToolTip
property of their data control, such as a
TextBox
or a
DropDownList
. The
Boolean_Edit
,
ForeignKey_Edit
, and
ManyToMany_Edit
field templates do not support the
Description
annotation out of the box. However, it is easy enough to fix this problem by adding code
similar to the following snippet. This example was taken from the
Boolean_Edit
field
template in the source code accompanying this topic:
protected void Page_Load(object sender, EventArgs e)
{
this.checkBox.ToolTip = this.Column.Description;
}
NOTE
By design, the
DisplayAttribute
cannot be applied to classes; it contains many prop-
erties that simply would not be applicable. To provide a human-readable name for an
entity type, you need to use the
DisplayNameAttribute
, as shown in here:
[DisplayName(“Order Items”)
partial class Order_Detail
{
}
After specifying which properties of an entity should appear on a dynamic form, in what
order they should appear, and what labels they should display, you might also need to
specify which field templates will be used for data entry and how they should be config-
ured.
Making Properties Read-Only
One of the important decisions to make when designing entities in your application is
whether a particular property can be modified by the user directly or supplied by the
system and displayed to the user in Read-only mode. In a
custom
page or template, you
can specify whether an Edit mode or a Read-only field template will be loaded by setting
the
Mode
property of the
DynamicControl
or
DynamicField
explicitly in markup:
<asp:DynamicControl runat=”server” DataField=”SubmittedDate”
Mode=”ReadOnly”
/>
When the
DynamicControl
instances are generated
dynamically
, the field template mode
needs to come from the model. If you were using a code-first or model-first approach in