RequiredFieldValidator Control
Evaluates the value of an input control to ensure that the user enters a value.Syntax :
<asp:RequiredFieldValidator ID="req" runat="server" ControlToValidate="txt" ErrorMessage="Please Enter Required value" Display="Dynamic" ></asp:RequiredFieldValidator>
Where
ControlToValidate= "Control which have to validate"
ErrorMessage ="Define custom error message
" Display= "Error message display property :
Three types Dynamic,Static,None
Example :
Default.aspx :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Required Field validator Example</title>
</head>
<body>
<form id="form1" runat="server">
<h1>
Required Field validator Example
</h1>
<div>
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="req" runat="server" ControlToValidate="txt" ErrorMessage="Please enter text box value" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Submit" CausesValidation="true"/>
</div>
</form>
</body>
</html>
If you are searching life partner. your searching end with kpmarriage.com. now kpmarriage.com offer free matrimonial website which offer free message, free chat, free view contact information. so register here : kpmarriage.com- Free matrimonial website
0 comments:
Post a Comment