views:

506

answers:

2

I'd like a way to both show an asterisk by an invalid field and show a verbose message in a validation summary. However, setting Display to "NONE" in the validation control suppresses any message that would appear next to the field to validate.

Is there a way to get this kind of hybrid function?

+9  A: 

Yes.

Set the text property to "*" and the ErrorMessage property to the actual error message. Something like.

<asp:RequiredFieldValidator id="ValidateMyField" runat="server" text="*" 
errormessage="Hey, you must really specify something" 
controltovalidate="YourControl" />

For the display you can use display="Dynamic" to have the * only take up space on an actual error.

Mitchel Sellers
A: 
 <asp:ValidationSummary ID="valSummary" runat="server" />
<asp:CustomValidator ID="valUserNameTaken" runat="server" ErrorMessage="User name is already used in this system, please choose another.">*</asp:CustomValidator>
BPAndrew