Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何使验证图标显示在asp:textbox旁边?_Asp.net_Validation - Fatal编程技术网

Asp.net 如何使验证图标显示在asp:textbox旁边?

Asp.net 如何使验证图标显示在asp:textbox旁边?,asp.net,validation,Asp.net,Validation,使用这个代码,我可以得到一个非常俗气的红字消息 <form id="frmValidator" action="required.aspx" method="post" runat="server"> Enter Your Name: <asp:TextBox id="txtName" runat="server" /> <asp:RequiredFieldValidator id="valTxtName" ControlToVali

使用这个代码,我可以得到一个非常俗气的红字消息

<form id="frmValidator" action="required.aspx" method="post" runat="server">    
    Enter Your Name:
    <asp:TextBox id="txtName" runat="server" />
    <asp:RequiredFieldValidator id="valTxtName" ControlToValidate="txtName" ErrorMessage="Please enter your name!" runat="server" />

    <br />
    <asp:button id="btnSubmit" text="Submit" runat="server" />

</form>

输入您的姓名:

有没有办法让我的绿色图标(我有这个图像,所以我想我只需要参考它)在控件旁边逐渐消失


非常感谢。:)

将ErrorMessage属性设置为指向图像的链接

e、 g.
ErrorMessage=''

请参阅MSDN文章。

您可以这样做

<%@ 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></title>
    <style type="text/css">
        </style>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            BorderStyle="None" ControlToValidate="TextBox1" CssClass="newStyle1"></asp:RequiredFieldValidator>
    </div> 
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>

.newStyle1
{
    background-image: url('Pic.png');
    width: 500px;
    height: 300px;
}

.新闻风格1
{
背景图片:url('Pic.png');
宽度:500px;
高度:300px;
}
因此,基本上没有任何错误消息的文本,并在验证控件中设置css属性,使其具有css类