System.Web 1.0.5000.0 2.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Web.UI.WebControls.Label System.Web.UI.IValidator System.ComponentModel.Designer("System.Web.UI.Design.WebControls.BaseValidatorDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner") System.ComponentModel.DefaultProperty("ErrorMessage") The class provides the core implementation for all validation controls. Validation controls are used to validate user input in an associated input control. When the user enters a value that fails validation, the validation control displays an error message. Because a validation control is separated from the input control, you can position the error message anywhere on the page relative to the input control. ASP.NET provides several validation controls that perform specific types of validation. The following table describes these controls. Validation control Description Validates a value against the value entered into another input control, against a constant value, or against a proper data type by setting the property to . Validates a value using a user-provided custom validation routine. Validates whether a value is within a range of values. Validates a value using a regular expression. Validates that a value was entered in a required field. Validation controls always validate the associated input control on the server. Validation controls also have complete client-side implementation that allows script-enabled browsers (such as Microsoft Internet Explorer version 4.0 and later) to perform validation on the client. Client-side validation enhances the validation process by checking user input before it is sent to the server. This allows errors to be detected on the client before the form is submitted, avoiding the round trip of information necessary for server-side validation. Multiple validation controls can be used with an individual input control to validate different criteria. For example, you can apply multiple validation controls on a control. You can use a control to ensure that the value entered in the control is within a set range, and a control to ensure that the user enters a value. ASP.NET provides many controls that have the ability to post back to the server. When one of these controls has its CausesValidation property set to true, validation is performed when the control posts back to the server. The following controls have the ability to post back to the server: Some of these controls post back to the server only when the AutoPostBack property is set to true. These controls each have a ValidationGroup property that, when set, validates only the validation controls within the specified group when the control triggers a post back to the server. To group validation controls, set the property of each validation control to the same value. To associate an input control with a validation control, use the property. To specify the text to display in a validation control when validation fails, use the property. You can also display a summary of all controls that fail validation in the page by using a control. To specify the text to display in a control, use the property. If you set the property without setting the property, the value of the property is also displayed in the validation control. When using validator controls, you should always check the results of server-side validation before performing any processing. After a postback but before your event methods are called, the page calls the validator controls and aggregates their results into the property. (You can also call the validator controls explicitly using the Validate method.) In your own code, you should check that the property returns true before processing input. Even though script-enabled browsers might prevent a postback from occurring on the client if a validation check has failed, you should always also check in server code before processing validated data. You can also manually perform validation. To validate all validation controls on the page, use the method. Individual validation controls can be validated by using the method of the control. If you use the property in a Page_Load method, you must first explicitly call the method. Because validation occurs after the event for the page, but before the event handler for the Click or Command events, the property is not updated until the method is called. As an alternative, you can place your code in the event handler for the Click or Command event instead of the Page_Load method. Not all Web server controls support validation controls. The standard controls that can be validated with a validation control are: For an input control to be validated, the attribute must be applied to the control. When you use validator controls that derive from inside an 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 control for partial-page updates, see Partial-Page Rendering Overview. When validation fails, you can set the focus on the associated input control by setting the property to true. For a list of initial property values for an instance of , see the constructor.

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.
Serves as the abstract base class for validation controls.
Constructor This constructor is not called directly. Validation controls that inherit from this class can call this constructor from their own constructors to initialize the base properties. The following table shows initial property values for an instance of . Property Initial value true true false Initializes a new instance of the class. 1.0.5000.0 2.0.0.0 Method System.Void The method is used to render the attributes of the control in the HTML tag for the control. This method is typically overridden by control developers in derived classes to insert the appropriate attributes and styles to the output stream for a control. Adds the HTML attributes and styles that need to be rendered for the control to the specified object. An that represents the output stream to render HTML content on the client. 1.0.5000.0 2.0.0.0 Property 1.0.5000.0 2.0.0.0 System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never) System.ComponentModel.Browsable(false) System.String To be added. This property is not supported. This property is supported only on the base class. This property is not supported. Method System.Void The method is a helper method used primarily by the method to verify whether the specified control is on the page and contains validation properties. This method does not return a value to report the result. Instead, it throws an exception when verification fails. This method is used primarily by control developers. Verifies whether the specified control is on the page and contains validation properties. The control to verify. Additional text to describe the source of the exception, if an exception is thrown from using this method. 1.0.5000.0 2.0.0.0 Method System.Boolean The method is a helper method used primarily by the property to determine whether the property contains a valid input control. To be a valid input control, the property must be set to some value and that value must be a control on the page that supports validation. This method is used primarily by control developers. Determines whether the control specified by the property is a valid control. true if the control specified by is a valid control; otherwise, false. 1.0.5000.0 2.0.0.0 Property System.String To be added: an object of type 'string' Use the property to specify the input control to validate. This property must be set to the ID of an input control for all validation controls except the control, which can be left blank. If you do not specify a valid input control, an exception will be thrown when the page is rendered. The ID must refer to a control within the same container as the validation control. It must be in the same page or user control, or it must be in the same template of a templated control. The standard controls that can be validated are: For an input control to be validated, the attribute must be applied to the control. All validation controls, except the control, will pass validation if the input control specified by the property contains no text. If you are using a control, the client-side and server-side validation functions are not called either. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets the input control to validate. 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue("") System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.ValidatedControlConverter)) System.Web.UI.Themeable(false) System.Web.UI.IDReferenceProperty(typeof(System.Web.UI.Control)) Method System.Boolean The method is a helper function that is used primarily by the property to determine whether the client's browser supports client script. For this property to return true, the following conditions must be true: The browser has client script enabled. The property of the object that is stored in the property is 1 or later. The property of the object that is stored in the property is 1.2 or later. This method is used primarily by control developers. Determines whether the validation control can perform client-side validation. true if the validation control can perform client-side validation; otherwise, false. 1.0.5000.0 2.0.0.0 Property System.Web.UI.WebControls.ValidatorDisplay To be added: an object of type 'ValidatorDisplay' Use the property to specify the display behavior of the error message in the validation control. The following table lists the different values that can be used. Display behavior Description None The validation message is never displayed inline. Static Space for the validation message is allocated in the page layout. Dynamic Space for the validation message is dynamically added to the page if validation fails. The display behavior depends on whether client-side validation is performed. If client-side validation is not active (because the browser does not support it or because it has been disabled by using the page directive or property), ValidatorDisplay.Static and ValidatorDisplay.Dynamic behave the same way: the error message takes up space only if it is displayed. The ability to dynamically allocate space for the message when it is not being displayed (ValidatorDisplay.Dynamic) only works with client-side validation. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets the display behavior of the error message in a validation control. 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue(System.Web.UI.WebControls.ValidatorDisplay.Static) System.Web.UI.Themeable(false) Property System.Boolean To be added: an object of type 'bool' Use the property to specify whether client-side validation is enabled. Validation controls always perform validation on the server. They also have complete client-side implementation that allows DHTML-supported browsers (such as Microsoft Internet Explorer 4.0 and later) to perform validation on the client. Client-side validation enhances the validation process by checking user input before it is sent to the server. This allows errors to be detected on the client before the form is submitted, avoiding the round trip of information necessary for server-side validation. By default, this value is set to true, which enables client-side validation if the browser supports it. You can disable client-side validation on a control-by-control basis. This is useful if dynamic updating on the client creates problems with the layout of the page, or if you want to execute some server code before validation takes place. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets a value indicating whether client-side validation is enabled. 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue(true) System.Web.UI.Themeable(false) Property System.Boolean a Use the property to specify whether the validation control is enabled. You can disable the validation control by setting this property to false. Setting either the or the property to false will prevent validation from being performed. This causes the property to always evaluate to true. The property is slightly different from the property. If the property for a validation control is set to true, but the property is set to false, the validation control is still rendered for client-side validation, but in a disabled state. You can then re-enable the validation control on the client by using DHTML script. Gets or sets a value that indicates whether the validation control is enabled. 1.0.5000.0 2.0.0.0 Property System.String To be added: an object of type 'string' When using a control, use the property to specify the text to display in the control when validation fails for the current validation control. To specify the text to display in the validation control itself, use the property. If you set the property without setting the property, the value of the property is also displayed in the validation control. The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization. Gets or sets the text for the error message displayed in a control when validation fails. 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue("") System.ComponentModel.Localizable(true) Method System.Boolean Use the method to determine whether the value in the input control specified by the property is valid. This method is used primarily by control developers. When overridden in a derived class, this method contains the code to determine whether the value in the input control is valid. true if the value in the input control is valid; otherwise, false. 1.0.5000.0 2.0.0.0 Property System.Drawing.Color a Use the property to specify a custom text color for the message displayed in the validation control when validation fails. Gets or sets the color of the message displayed when validation fails. 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue(typeof(System.Drawing.Color), "Red") Method System.String Use the method to get the client ID of the specified control. For more information, see . This method is used primarily by control developers. Gets the client ID of the specified control. The client ID of the specified control. The name of the control to get the client ID from. 1.0.5000.0 2.0.0.0 Method System.String Use the method to get the value associated with the specified input control, regardless of the control type. For example, you can use this method to get the value in a control, as well as the value of the selected item from a control. If the specified control cannot be found, null is returned. This method is used primarily by control developers. Gets the value associated with the specified input control. The value associated with the specified input control. The name of the input control to get the value from. 1.0.5000.0 2.0.0.0 Method System.ComponentModel.PropertyDescriptor a The method is a helper function that gets the validation property of the specified input control. This method is used primarily by control developers. Determines the validation property of a control (if it exists). A that contains the validation property of the control. 1.0.5000.0 2.0.0.0 Property System.Boolean To be added: an object of type 'bool' Use the property to determine whether the associated input control passes validation. Because the default value of this property is true, it will return true if you query this property before validation is performed. For example, this might occur if you attempt to use this property in the event of a page. The property is evaluated only when the method is called. You can call the method for each validation control on the page individually, or call all of them at once by using the method. Button controls with their CausesValidation property set to true will also call the method. It is possible to change the value of this property manually after validation has taken place. This allows you to override the validation result, if necessary. The property for the page is set to true only if the property for each validation control on the page is also set to true. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets a value that indicates whether the associated input control passes validation. 1.0.5000.0 2.0.0.0 System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden) System.Web.UI.Themeable(false) System.ComponentModel.DefaultValue(true) System.ComponentModel.Browsable(false) Method System.Void After this method calls the base control's method, it sets the property to if the following conditions are true: The property is not already set. The property indicates an ASP.NET version earlier than 4.0. By default, validator controls in ASP.NET 4 and later versions do not display errors in red. For information about how to control the visual appearance of validator controls, see Validating User Input in ASP.NET Web Pages. This method also registers the validation control on the page. Raises the event. A that contains the event data. 1.0.5000.0 2.0.0.0 Method System.Void This method has been overridden to check the client browser and configure the validation control for compatibility prior to rendering. Raising an event invokes the event handler through a delegate. For more information, see Raising an Event. The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. Raises the event. A that contains the event data. 1.0.5000.0 2.0.0.0 Method System.Void This method has been overridden to unregister the validation control on the page. Raising an event invokes the event handler through a delegate. For more information, see Raising an Event. The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. Raises the event. A that contains the event data. 1.0.5000.0 2.0.0.0 Property System.Boolean To be added: an object of type 'bool' Use the property to determine whether the property contains a valid input control. To be a valid input control, the property must be set to a control on the page. This property is used primarily by control developers. Gets a value that indicates whether the control specified by the property is a valid control. 1.0.5000.0 2.0.0.0 Method System.Void Use the method to register code on the page to perform client-side validation. This method is used primarily by control developers. Registers code on the page for client-side validation. 1.0.5000.0 2.0.0.0 Method System.Void Use the method to register an ECMAScript array declaration using the array name Page_Validators. This method is used primarily by control developers. Registers an ECMAScript array declaration using the array name Page_Validators. 1.0.5000.0 2.0.0.0 Method System.Void The method is used to generate the HTML markup for a validation control. Displays the control on the client. A that contains the output stream for rendering on the client. 1.0.5000.0 2.0.0.0 Property System.Boolean To be added: an object of type 'bool' Use the property to determine whether the client's browser supports "uplevel" rendering. For a browser to support "uplevel" rendering, it must support Microsoft Internet Explorer Document Object Model (DOM) version 4 or later and ECMAScript version 1.2 or later. This property is used primarily by control developers. Gets a value that indicates whether the client's browser supports "uplevel" rendering. 1.0.5000.0 2.0.0.0 Property 2.0.0.0 System.ComponentModel.DefaultValue(false) System.Web.UI.Themeable(false) System.Boolean To be added. Use the property to specify whether focus is automatically set to the control specified by the property when this validation control fails. This allows the user to quickly update the appropriate control. If multiple validation controls fail and this property is set to true, the control specified in the property for the first validation control receives focus. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets a value that indicates whether focus is set to the control specified by the property when validation fails. Property 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue("") System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerDefaultProperty) System.String To be added. Use the property to specify the text to display in a validation control when validation fails. You can also display a summary of all controls that fail validation in the page by using a control. To specify the text to display in a control, use the property. If you set the property without setting the property, the value of the property is also displayed in the validation control. Gets or sets the text displayed in the validation control when validation fails. Method System.Void Use the method to perform validation on the associated input control. This method allows you to programmatically perform validation on the input control. The property is automatically updated with the validation results. Performs validation on the associated input control and updates the property. 1.0.5000.0 2.0.0.0 Property 2.0.0.0 System.ComponentModel.DefaultValue("") System.Web.UI.Themeable(false) System.String To be added. ASP.NET provides many controls that have the ability to post back to the server. When one of these controls has its CausesValidation property set to true, validation is performed when the control posts back to server. The following controls have the ability to post back to the server: Some of these controls post back to the server only when the AutoPostBack property is set to true. These controls each have a ValidationGroup property that, when set, validates only the validation controls within the specified group when the control triggers a post back to the server. Use the property to assign a validation control to a validation group. The class also exposes a method and a method that accept a input parameter. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets the name of the validation group to which this validation control belongs.