Name
RequiredFieldValidator
Synopsis
This class represents a validation control that is used to force user entry in a
corresponding input control, like a TextBox
. Validation fails if the value
in the input control does not differ from the InitialValue
property. By default, InitialValue
is
set to System.String.Empty
and validation will succeed as long as
some information has been added to the input control.
You can use a combination of different validation controls for a single control. For
example, you could use a RequiredFieldValidator
to ensure that a
value is entered and a RangeValidator
to ensure that the value is within a specified data range. This is often required, as
validators like RangeValidator
will
automatically validate a control if it is empty, regardless of the properties you
have set.
Public Class RequiredFieldValidator : Inherits BaseValidator ' Public Constructors Public Sub New() ' Public Instance Properties Public Property InitialValue As String ' Protected Instance Methods Overrides Protected Sub AddAttributesToRender( ByVal writer As System.Web.UI.HtmlTextWriter) Overrides Protected Function EvaluateIsValid() As Boolean End Class
Hierarchy
System.Object→ System.Web.UI.Control(System.ComponentModel.IComponent
, System.IDisposable
, System.Web.UI.IParserAccessor
, System.Web.UI.IDataBindingsAccessor)→WebControl(System.Web.UI.IAttributeAccessor)→Label→BaseValidator(System.Web.UI.IValidator)→ RequiredFieldValidator
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.