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..
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.
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>
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.)
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.
© 2022 - 2024 — McMap. All rights reserved.
.errorMsg{color:red;}
– Unearth