-->
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Text="" InitialValue="none" SetFocusOnError="true" ControlToValidate="dropFavoriteColor" runat="server" />
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequiredValidatorDemo.aspx.cs" Inherits="WebMSV.Programming.RequiredValidatorDemo" %> <!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></title> <style> .column { float: left; width: 30%; margin-left: 10px; background-color: white; border: solid 1px black; padding: 10px; border-radius: 25px; } fieldset { background-color: #a9a9a9; border: solid 2px #d81a72; border-radius: 20px; color:Black; } </style> </head> <body> <form id="form1" runat="server"> <div class="column"> <fieldset> <legend>Required Validator Demo</legend> <asp:Label ID="lblName" Width="100" AssociatedControlID="txtName" runat="server"> Name:</asp:Label> <asp:TextBox ID="txtName" MaxLength="20" runat="server" Width="100"></asp:TextBox> <asp:RequiredFieldValidator ID="rfvName" ControlToValidate="txtName" Text="Enter Name" BackColor="#2be274" ForeColor="#d8341a" EnableClientScript="true" SetFocusOnError="true" runat="server"></asp:RequiredFieldValidator> <br /> <br /> <asp:Button runat="server" ID="btnValidate" Text="Validate" /> </fieldset> </div> </form> </body> </html>
Thanks for reading Asp.Net RequiredFieldValidator Control