The RequiredFieldValidator control ensures that the required field is not empty. It is generally tied to a text box to force input into the text box.
RequiredFieldValidator validation control make an asp.net web server input control as like a mandatory field.
DEMO
You can use it to make sure that the user has entered something in a TextBox control
Property | Description |
---|---|
BackColor | The background color of the RequiredFieldValidator control |
ControlToValidate | The id of the control to validate |
Display | The display behavior for the validation control. Legal values are:
|
EnableClientScript | A Boolean value that specifies whether client-side validation is enabled or not |
Enabled | A Boolean value that specifies whether the validation control is enabled or not |
ErrorMessage | The text to display in the ValidationSummary control when validation fails.Note: This text will also be displayed in the validation control if the Text property is not set |
ForeColor | The foreground color of the control |
id | A unique id for the control |
InitialValue | Specifies the starting value of the input control. Default value is "" |
IsValid | A Boolean value that indicates whether the control specified by ControlToValidate is determined to be valid |
runat | Specifies that the control is a server control. Must be set to "server" |
Text | The message to display when validation fails |
First - Add - New WebForm - Select Textbox & DropDownlist from ToolBox
Next - Go to - ToolBox - Validation -Select - Required Field Validation - for Textbox & DropDownlist
Next - Select Required Field Validation - F4 press Property window below like that
Select - DropDownList -Required Field Validation - Error Message write required - Control to validate DropDownList ID - Initial values Put Select Country or your dropdownlist values - index 0
Next - Click Save Button Without Fill Values Show below like that Error Message Show
Next - Fill Values After Click - Save Button - Save the values
0 comments:
Post a Comment