Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Changing the font color of a RegularExpressionValidator with CSS

Changing the font color of a RegularExpressionValidator with CSS

Scheduled Pinned Locked Moved ASP.NET
csshelpquestion
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Talal Sultan
    wrote on last edited by
    #1

    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

    E N 2 Replies Last reply
    0
    • T Talal Sultan

      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

      E Offline
      E Offline
      eyeseetee
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • T Talal Sultan

        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

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        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

        T 1 Reply Last reply
        0
        • E eyeseetee

          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

          T Offline
          T Offline
          Talal Sultan
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • N N a v a n e e t h

            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

            T Offline
            T Offline
            Talal Sultan
            wrote on last edited by
            #5

            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

            E N 2 Replies Last reply
            0
            • T Talal Sultan

              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

              E Offline
              E Offline
              eyeseetee
              wrote on last edited by
              #6

              try setting the font color in the actual validator syntax i.e. ps didnt seem to show the code i put in modified on Wednesday, March 5, 2008 4:30 AM

              1 Reply Last reply
              0
              • T Talal Sultan

                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

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                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

                E T 2 Replies Last reply
                0
                • N N a v a n e e t h

                  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

                  E Offline
                  E Offline
                  eyeseetee
                  wrote on last edited by
                  #8

                  an extension on what I had already said.. but I will accept it ;P

                  1 Reply Last reply
                  0
                  • N N a v a n e e t h

                    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

                    T Offline
                    T Offline
                    Talal Sultan
                    wrote on last edited by
                    #9

                    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

                    N 1 Reply Last reply
                    0
                    • T Talal Sultan

                      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

                      N Offline
                      N Offline
                      N a v a n e e t h
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups