views:

2235

answers:

5

I can't seems to change the default color of the required field validator. In the source it is:

<span class="required">*</span>
<asp:RequiredFieldValidator ID="valReq_txtTracks" runat="server"
    ControlToValidate="txtTracks"
    Display="Dynamic" />

Here's what I have in my .skin file:

<asp:RequiredFieldValidator runat="server" 
    CssClass="error-text"
    ErrorMessage="required" />

In the rendered source I see:

<span class="required">*</span>
<span id="ctl00_ctl00_cphContent_cphContent_valReq_txtTracks" class="error-text" style="color:Red;display:none;">required</span>

Notice the "style=color:Red;". That needs to go. I can't override it with a css-class because it's inline CSS. What should I do?

A: 

I read somewhere to use the !important tag in your css class to override the inline css...

bob
That worked too, but I wanted the color style removed by the asp.net engine, not css inheritance. Thanks though!
craigmoliver
A: 

Did you try to add style attribute with empty string in the skin file:

<asp:RequiredFieldValidator runat="server" 
    CssClass="error-text"
    style=""
    ErrorMessage="required" />
mnour
I tried that, it just appended it.
craigmoliver
+7  A: 

There is a RequiredFieldValidator.ForeColor property you can set to control the color. Note that if you want to set the color in CSS, then you need to set ForeColor="" to clear it on the control.

Mark Brackett
I added ForeColor="" to the .skin file and that did the trick, thanks!
craigmoliver
A: 

Adding style attribute wont help.

One way is to use foreColor, but then you cant use the color from css...

thanks, but that was answered by Mark three months ago.
craigmoliver
A: 

Using !important seems to work fine in Firefox and IE, but for some reason not in Google Chrome... no biggie though, Chrome's share is still very low.

.form_error { font: bold 15px arial black,arial,verdana,helvetica !important; color: #ff0000 !important; }