System.Web.UI.WebControls.RequiredFieldValidator Class

Makes the associated input control a required field.

See Also: RequiredFieldValidator Members

Syntax

[System.Web.UI.ToolboxData("<{0}:RequiredFieldValidator runat="server" ErrorMessage="RequiredFieldValidator"></{0}:RequiredFieldValidator>")]
public class RequiredFieldValidator : BaseValidator

Remarks

Use this control to make an input control a required field. The input control fails validation if its value does not change from the RequiredFieldValidator.InitialValue property upon losing focus.

Multiple validators can be associated with the same input control. For example, a System.Web.UI.WebControls.RequiredFieldValidator can be used to ensure input to a control, while at the same time a System.Web.UI.WebControls.RangeValidator can be used to ensure that the input is within a specified data range.

Note:

When you use the System.Web.UI.WebControls.RequiredFieldValidator control inside an System.Web.UI.UpdatePanel control, make sure that the validator control and the control it is associated with are in the same panel. For more information about using the System.Web.UI.UpdatePanel control for partial-page updates, see Partial-Page Rendering Overview.

For additional information on validation controls, see System.Web.UI.WebControls.BaseValidator.

Accessibility

For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0