
264
|
Chapter 12: The Page Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
<asp:label id="Message" runat="server"/>
</body>
</html>
Notes
Because we are displaying only properties from the validator controls that are
inherited from the BaseValidator control (from which all validation controls are
derived), we don’t need to cast the validator to its specific type before accessing
the properties. If, however, we wanted to display a property that was specific to
the type of validator used (such as the ValidationExpression property of the
RegularExpressionValidator class), we would need to cast the control to the
correct type. In Visual Basic .NET, this is done using the
CType keyword.
Methods Reference
DataBind
Page.DataBind()
Evaluates and resolves any data-binding expressions in the page. It also calls
DataBind on all child controls.
Parameters
None.
Example
The following code example uses a data-binding expression to set the ForeColor
attribute of a label control tag to the value of local variable named color. When
the DataBind method is called in Page_Load, the value of the Color variable is
assigned to the
ForeColor attribute (which is effectively the same as setting the
ForeColor property in code):
<%@ Page Language="vb" %>
<html>
<head>
<title></title>
<script runat="server">
Dim Color As System.Drawing.Color = System.Drawing.Color.Red ...