Introducation:In this Example iam going to explain how to use RequiredFieldValidator in Asp.net
Description:
The RequiredFieldValidator control is used to make an input control a required field.
With this control, the validation fails if the input value does not change from its initial value. By default, the initial value is an empty string ("").
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-left:250px">
<asp:Label ID="Label1" runat="server" Text="First Name:"></asp:Label>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please
Enter First Name" ControlToValidate="txtFirstName"> </asp:RequiredFieldValidator>
</div>
<div style="margin-left:320px;margin-top:50px;">
<asp:Button ID="Button1" runat="server" Text="Submit" />
</div>
</form>
</body>
</html>
|
No comments:
Post a Comment