Showing error image when validation fails using validation control in asp.net c#
Many times we want to set image in validation
control when validation fails because we want improve our web site or client’s
requirement. So in this article, we have set an image inside of the error
message of control.
Source Code:-
<%@
Page Language="C#" AutoEventWireup="true" CodeFile="imagevaildation.aspx.cs"
Inherits="imagevaildation" %>
<!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> Showing
error image when validation fails using validation control </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1"
Display="Dynamic" ErrorMessage='<img src="error.jpg"/>'></asp:RequiredFieldValidator>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</div>
</form>
</body>
</html>
Out-Put:-
Showing error image when validation fails using validation control in asp.net c#
Reviewed by NEERAJ SRIVASTAVA
on
4:40:00 PM
Rating:
No comments: