How can I make Valdator red?

I have a problem with pointing the RequiredFieldValidator color to red, but when I publish the website on the web, the RequiredFieldValidator color 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

+6
source share
3 answers

By default, the validator is red - it does not need to be changed. Check your css to make sure it does not overcome anything. Also check the class for which the required identifier is set, and make sure that it does not include the color property.

+3
source

Rohan

Perhaps this was your problem. I had the same problem.

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

Output of your source in 3.5 format:

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

Original output in 4.0:

 <span id="ctl01_YourControl" style="visibility:hidden;">*</span> 
+14
source

In ASP.NET 4.0, there are changes to the output cleanup code that include:

xhtmlConformance is Strict. Menus are displayed as lists, not tables. Extraneous properties, such as border = 0, are removed from the selected markup. Even the error text in the validation controls is no longer set to red. Now the rendering of the external table for the template controls can be controlled using the newRenderOuterTable property. For compatibility, you can make your output the same as in ASP.NET 3.5 using controlRenderingCompatibilityVersion

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

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

I am so happy that I decided this. And I am surprised that I could not find more people going on the same problem. It seems that the options in my case are to use this compatibility option or set ForeColor of all my validation controls to Red. (I will probably do this last.)

+5
source

Source: https://habr.com/ru/post/906074/


All Articles