Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i make Valdator's color red?

i have a problem that i have specified the color of RequiredFieldValidator to red but when i publish the website on net the color of RequiredFieldValidator is changed to black. it works fine in localhost. what could be the problem ? thanks in advance..

this is the image like what i want

like image 779
Rohan Avatar asked Jan 16 '12 06:01

Rohan


3 Answers

Rohan,

This may have been your issue. I had the same problem.

By default, framework 4.0 will make all validator error messages black. You will need to explicitly set the ForeColor of all validators to red if you target framework 4.0.

Your source output in 3.5:

<span id="ctl01_YourControl" style="color:Red;visibility:hidden;">*</span>

Your source output in 4.0:

<span id="ctl01_YourControl" style="visibility:hidden;">*</span>
like image 187
AnotherDeveloper Avatar answered Oct 28 '22 08:10

AnotherDeveloper


ASP.NET 4.0 has changes to output cleaner code, which include:

xhtmlConformance is set to Strict. Menus are rendered as lists rather than tables Extraneous properties like border=0 are removed from the emitted markup. Even the error text on validation controls is no longer set to red. The rendering of the outer table for templated controls can now be controlled with the newRenderOuterTable property. For compatibility, you can make your output look the same as it did in ASP.NET 3.5 with the controlRenderingCompatibilityVersion

> <?xml version="1.0"?> <configuration>   <system.web>
>     <compilation debug="false" targetFramework="4.0" />
>     <pages controlRenderingCompatibilityVersion="3.5" />   </system.web> </configuration>

More information is available at http://msdn.microsoft.com/en-us/library/system.web.ui.control.renderingcompatibility.aspx.

I'm so happy to have resolved this. And I'm surprised I couldn't find more people posting about this same issue. It looks like the options in my case are to use this compatibility setting or set the ForeColor of all my validation controls to Red. (I'll probably do that latter.)

like image 41
Syed Fahad Ali Avatar answered Oct 28 '22 06:10

Syed Fahad Ali


By default the validator is red - you shouldn't need to change it. Check your css to make sure it is not getting over ridden by anything. Also check the class that the requiredfieldvalidator is set to and make sure it does not include a color property.

like image 3
Christopher O'Neil Avatar answered Oct 28 '22 06:10

Christopher O'Neil