Changing the font color of a RegularExpressionValidator with CSS
-
Hi, I was wondering if we could change the color of the RegularExpressionValidator (or any validator) via CSS. It seems that even if we apply a color in the css, it's always the one defined in the properties (in the designer) that is taken into account. I have checked the source of the page and there is always a "style" attribute that is placed just after the "class" attribute, which leads to the "style" overriding the "class" and thus applying the color that is given in the designer. I couldn't find a way to make it stop generating the "style" attribute. It's always there!! I have tried google to search for a similar case. There are people complaining about the same problem but it seems the only solutions is to create a NEW custom validator X| :doh: If removing it is not an option, is there a way to make both attributes switch places in the code? that way the "class" would override the "style". Thanks a lot Talal
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
-
Hi, I was wondering if we could change the color of the RegularExpressionValidator (or any validator) via CSS. It seems that even if we apply a color in the css, it's always the one defined in the properties (in the designer) that is taken into account. I have checked the source of the page and there is always a "style" attribute that is placed just after the "class" attribute, which leads to the "style" overriding the "class" and thus applying the color that is given in the designer. I couldn't find a way to make it stop generating the "style" attribute. It's always there!! I have tried google to search for a similar case. There are people complaining about the same problem but it seems the only solutions is to create a NEW custom validator X| :doh: If removing it is not an option, is there a way to make both attributes switch places in the code? that way the "class" would override the "style". Thanks a lot Talal
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
Talal Sultan wrote:
one defined in the properties (in the designer)
By looking at the above quote does this mean you are not actiually writing the code for it but creating it in the designer? If so just delete the style from the code and apply the class might work
-
Hi, I was wondering if we could change the color of the RegularExpressionValidator (or any validator) via CSS. It seems that even if we apply a color in the css, it's always the one defined in the properties (in the designer) that is taken into account. I have checked the source of the page and there is always a "style" attribute that is placed just after the "class" attribute, which leads to the "style" overriding the "class" and thus applying the color that is given in the designer. I couldn't find a way to make it stop generating the "style" attribute. It's always there!! I have tried google to search for a similar case. There are people complaining about the same problem but it seems the only solutions is to create a NEW custom validator X| :doh: If removing it is not an option, is there a way to make both attributes switch places in the code? that way the "class" would override the "style". Thanks a lot Talal
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
Strange. It just worked fine for me. Which is your ASP.NET version ?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
Talal Sultan wrote:
one defined in the properties (in the designer)
By looking at the above quote does this mean you are not actiually writing the code for it but creating it in the designer? If so just delete the style from the code and apply the class might work
Well the HTML code looks like this:
<asp:RegularExpressionValidator ID="emailValidator" runat="server" ControlToValidate="txtAddEmail" Display="Static" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" CssClass="SmallWarning"></asp:RegularExpressionValidator>
In this code, there is even no reference to the ForeColor of the control, but this code generates the below HTML code when the server sends back the page:<span id="ctl00_def_vldAddAlternateEmail" class="SmallWarning" style="color:Red;visibility:hidden;">Please enter a valid email address.</span>
You can see that the "style" attribute is there and it is always AFTER the "class" attribute :S And I didn't find a way to set the ForeColor to nothing, the default is red and this is what is used when I don't specify it in the HTML code.-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
-
Strange. It just worked fine for me. Which is your ASP.NET version ?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
I am using .NET 2.0 and VS 2005. It is driving me nuts! The weird things is that the CSS is applied because the font size changes as I have set it in the CSS but the font doesn't change. If you can check the reply I just posted above, you can see how the HTML code is written and how it is generated back by the server.
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
-
I am using .NET 2.0 and VS 2005. It is driving me nuts! The weird things is that the CSS is applied because the font size changes as I have set it in the CSS but the font doesn't change. If you can check the reply I just posted above, you can see how the HTML code is written and how it is generated back by the server.
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
-
I am using .NET 2.0 and VS 2005. It is driving me nuts! The weird things is that the CSS is applied because the font size changes as I have set it in the CSS but the font doesn't change. If you can check the reply I just posted above, you can see how the HTML code is written and how it is generated back by the server.
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
Here you go
<asp:RequiredFieldValidator ForeColor=""
CssClass="SmallWarning"
ID="RequiredFieldValidator1"
runat="server"
ErrorMessage="RequiredFieldValidator"
ControlToValidate="TextBox1"
/>This will show color given in the style sheet.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
Here you go
<asp:RequiredFieldValidator ForeColor=""
CssClass="SmallWarning"
ID="RequiredFieldValidator1"
runat="server"
ErrorMessage="RequiredFieldValidator"
ControlToValidate="TextBox1"
/>This will show color given in the style sheet.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
Here you go
<asp:RequiredFieldValidator ForeColor=""
CssClass="SmallWarning"
ID="RequiredFieldValidator1"
runat="server"
ErrorMessage="RequiredFieldValidator"
ControlToValidate="TextBox1"
/>This will show color given in the style sheet.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
Thanks, it never occurred to me that I could actually have an empty ForeColor. It works well! :) Cheers!
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
-
Thanks, it never occurred to me that I could actually have an empty ForeColor. It works well! :) Cheers!
-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
Glad to know it worked
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions