Issue with ValidationSummary Control, ErrorMessage and Text

P

PeterKellner

I'm wanting to just show the error in a ValidationSummary control, not
next to the actual TextField I'm putting a RequiredFieldValidator next
to. I don't even want the little "*" showing which field it is.
(strange requirement, but that's the way it is).

I've found that if I set the attribute Text="" (zero length string),
it always uses the ErrorMessage instead of Text. I need the
ErrorMessage because that is what is going to show up in the
ValidationSummary control.

Any ideas how to force the text to blank right next to the control?

Thanks,
Peter Kellner
http://peterkellner.net
 
K

Ken Cox [Microsoft MVP]

Hi Peter,

Does it do what you want if you set the validator to display="None" ?

Ken
Microsoft MVP [ASP.NET]



<%@ Page Language="VB" %>

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

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:textbox id="TextBox2" runat="server"></asp:textbox>
<asp:requiredfieldvalidator id="RequiredFieldValidator1"
runat="server" controltovalidate="TextBox1" display="None"
errormessage="RequiredFieldValidator"></asp:requiredfieldvalidator><br />
<br />
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
<asp:requiredfieldvalidator id="RequiredFieldValidator2"
runat="server" controltovalidate="TextBox2"
errormessage="RequiredFieldValidator"></asp:requiredfieldvalidator><br />
<br />
<asp:validationsummary id="ValidationSummary1" runat="server" />
<br />
<br />
<asp:button id="Button1" runat="server" text="Button" /></div>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top