The list of elements of the message category is shown in the table below.
Element Type |
Source Content Representation |
Web Controls |
messages (for page) |
Representation is shown in the discussion below |
asp:ValidationSummary |
messages (for element) |
Representation is shown in the discussion below |
(See validators attribute of the element descriptor) |
messages (for element)
The messages for specific element could be displayed next to an input element. The annotation would simply denote the id of the element, as shown below.
<tr>
<th class="rightLabel">
<label for="categoryName">Category Name</label>
<font color="red">*</font>
</th>
<td align="left">
<input type="text" name="categoryName" value="">
</td>
<td>
<!-- aws:element type="messages" id="categoryNameValidator" -->
Category Name is required.
<!-- /aws:element -->
</td>
</tr>
This shows up in the browser as follows:
The messages elements represent messages for the page as well as for a single element. Whenever an id attribute is specified, the message that pertains to the identified element is specified to show.
The implementation depends on the validation specifications. It is within such specification that the messages are stipulated. Since multiple validators could be involved, the issue of layout needs to be considered. For such consideration, check the element descriptor validator attribute.
The implementation of the sample specification shown above is implemented below.
<tr>
<th class="rightLabel">
<asp:Label AssociatedControl="categoryName" runat="server"
Text="Category Name" />
<font color="red">*</font>
</th>
<td align="left">
<asp:TextBox ID="categoryName" runtat="server"
Text='<%# Bind("CategoryName" %>' />
</td>
<td>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server"
Text="Category Name is required"
ControlToValidate="categoryName"
EnableClientScript="false"/>
</td>
</tr>
messages (for page)
This messages element captures the various ways most platforms would provide text messages for display on the page view.
The representation in the content source is with annotations.
<!-- aws:element type="messages" value="error" -->
<!-- mock presentation could be included here -->
<!-- /aws:element -->
These annotations would be placed in the source content. There is no need for corresponding entry in the descriptors. Other descriptor specifications could influence the final implementation. Example is the form descriptor attributes, like server or client validations enabled attributes of the form descriptor.
Within the annotations would be the mock representation of the messages. The value would be as recognized on the platform. For example, some platforms have message categories like error, info, warning, debug, etc.
The position of the representation outside a form, would dictate that the message is for the page, whereas within a form, it is for the specific form.
The implementation on ASP.NET platform is through the ValidationSummary control, which is used to display a summary of all validation errors occurring on a page.
These error messages displayed are accumulated from each of the validation controls. The following are the properties that could be used to customize the display.
Properties
Property |
Description |
DisplayMode |
Specify the layout of the error messages; possible values are:
- BulletList
- List
- SingleParagraph
|
EnableClientScript |
Enables whether the ValidationSummary control updates itself using client-side script. |
Enabled |
Enables the control |
ForeColor |
The fore color of the control |
HeaderText |
A header in the ValidationSummary control |
id |
The unique identifier for the control |
runat |
The control must be set to run at the server side. |
ShowMessageBox |
The Boolean value used to specify whether or not the summary should be displayed in a message box |
ShowSummary |
The Boolean value indicating whether the validation summary is displayed inline. |
|