Google Answers Logo
View Question
 
Q: ASP.NET RequiredFieldValidator changing font color of field name ( No Answer,   3 Comments )
Question  
Subject: ASP.NET RequiredFieldValidator changing font color of field name
Category: Computers > Programming
Asked by: royafork-ga
List Price: $2.00
Posted: 22 Nov 2004 12:08 PST
Expires: 06 Dec 2004 14:04 PST
Question ID: 432434
I would like to know if there is a way to use the
RequiredFieldValidator in such a way that would turn the label "Street
Address" red (see below) if the field were left blank and submitted.
Currently I only see the ability to add error text beside the field.
Is it possible to use the RequiredFieldValidator with an existing
label, and if so, how?

 Street Address   [     ]
Answer  
There is no answer at this time.

Comments  
Subject: Re: ASP.NET RequiredFieldValidator changing font color of field name
From: sujitnair-ga on 26 Nov 2004 09:16 PST
 
You can add the required field validator to an existing text field in
the following way

<asp:textbox ID="Street" runat="server" TextMode="SingleLine"
TabIndex="1" CssClass="text"  /> <br> <asp:RequiredFieldValidator
id="StreetValidator" runat="server" ErrorMessage="Enter a street
address" ControlToValidate="Street" CssClass="text" 
Display="Dynamic"/>

You can change the css class to alter the colour of the error message.
Subject: Re: ASP.NET RequiredFieldValidator changing font color of field name
From: royafork-ga on 29 Nov 2004 08:54 PST
 
Thanks, that is very helpful.

Is there a standard method for loading a new stylesheet on Postback in
ASP.NET? Or  a recommended way of changing the style for that one
particular CSS element?
Subject: Re: ASP.NET RequiredFieldValidator changing font color of field name
From: royafork-ga on 29 Nov 2004 10:26 PST
 
Actually, sorry, this does not help, because the
RequiredFieldValidator only registers after a Postback. Where is the
ErrorMessage text on the initial page load and how do I get it to
display?

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy