How to display custom error message using CSS and validation control ?



Hi

Recently i was doing some test using CSS.Then i got very nice css, which one we can use in our real time project.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomCSSTest.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.errors
{
border: solid 1px Blue;
background-color: #d0e6ff;
padding: 10px;
}

</style>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1"
runat="server" ErrorMessage="Enter Your Name Please!" CssClass="errors" ForeColor="Blue"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" />
</td>
<td>
</td>
</tr>
</table>
<div>

</div>
</form>
</body>
</html>

Advertisements
Posted in CSS. 2 Comments »

2 Responses to “How to display custom error message using CSS and validation control ?”

  1. Revathi Says:

    i was using it. it works super…

    • Chandra Dev Says:

      Nice to know.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: