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. asp:TextBox backgroundColor change also affects borderStyle?

asp:TextBox backgroundColor change also affects borderStyle?

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptarchitecturehelpquestion
3 Posts 2 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.
  • C Offline
    C Offline
    Cyrilix
    wrote on last edited by
    #1

    I have an ASP .NET page with some text boxes, where I set the javascript events onfocus and onblur to change the backgroundColor, so the code is something like what's below:

    function setBackgroundColor(elementID, color)
    {
    var control = document.getElementById(elementID);
    control.style.backgroundColor = color;
    }

    The problem is, as soon as this happens, the borderStyle also changes from the original flat/solid borderStyle to one that's 3D (not sure which one though). Does anyone know why these two backgroundColor and borderStyle properties are tied to each other and how I'd go about only changing just the backgroundColor?

    U 1 Reply Last reply
    0
    • C Cyrilix

      I have an ASP .NET page with some text boxes, where I set the javascript events onfocus and onblur to change the backgroundColor, so the code is something like what's below:

      function setBackgroundColor(elementID, color)
      {
      var control = document.getElementById(elementID);
      control.style.backgroundColor = color;
      }

      The problem is, as soon as this happens, the borderStyle also changes from the original flat/solid borderStyle to one that's 3D (not sure which one though). Does anyone know why these two backgroundColor and borderStyle properties are tied to each other and how I'd go about only changing just the backgroundColor?

      U Offline
      U Offline
      Uwe Keim
      wrote on last edited by
      #2

      The idea is that the browser uses the underlying OS's rendering capabilities to standard form controls (like buttons or text boxes). As soon as you change attributes/properties/styles that the OS cannot render anymore, the browser switches from an OS rendered control to an ownerdrawn control. Happens e.g. inside Google applications quite often, too. You could set the border always explicitely to avoid the "flipping" you described.

      • My personal 24/7 webcam - Always live ;-) • Holiday Season special – zeta producer Desktop 8 (CMS) including all modules for only $129! • Zeta Uploader - Easily send large files by e-mail. Windows and web client available.

      C 1 Reply Last reply
      0
      • U Uwe Keim

        The idea is that the browser uses the underlying OS's rendering capabilities to standard form controls (like buttons or text boxes). As soon as you change attributes/properties/styles that the OS cannot render anymore, the browser switches from an OS rendered control to an ownerdrawn control. Happens e.g. inside Google applications quite often, too. You could set the border always explicitely to avoid the "flipping" you described.

        • My personal 24/7 webcam - Always live ;-) • Holiday Season special – zeta producer Desktop 8 (CMS) including all modules for only $129! • Zeta Uploader - Easily send large files by e-mail. Windows and web client available.

        C Offline
        C Offline
        Cyrilix
        wrote on last edited by
        #3

        Interesting, thanks for the info. I tried setting the borderStyle to solid, and then it changed the border outline to a different color (black) than what the OS renders (I guess), which is something like a light blue-ish color. In the end, I just said "screw it, 3D border style it is", since it seemed to look alright.

        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