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. IDs and CSS

IDs and CSS

Scheduled Pinned Locked Moved ASP.NET
questionhtmlcsshelptutorial
4 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.
  • T Offline
    T Offline
    theJazzyBrain
    wrote on last edited by
    #1

    I am facing a bit of a problem with the IDs generated by the framework for HTML elements that exist within a user control or a web control that is added to the page dynamically. The framework goes and creates some kind of hierarchy and adds prefixes to the IDs. My question is how do you guys manage these when you want to create a unique CSS declaration for a specific element? For example, if I have a user control that generates a contact form, and I want to give to a textbox that exists within that contact form a unique style.

    Jason Kataropoulos

    Excellence is not an act, but a habit!

    Aristotle

    S 1 Reply Last reply
    0
    • T theJazzyBrain

      I am facing a bit of a problem with the IDs generated by the framework for HTML elements that exist within a user control or a web control that is added to the page dynamically. The framework goes and creates some kind of hierarchy and adds prefixes to the IDs. My question is how do you guys manage these when you want to create a unique CSS declaration for a specific element? For example, if I have a user control that generates a contact form, and I want to give to a textbox that exists within that contact form a unique style.

      Jason Kataropoulos

      Excellence is not an act, but a habit!

      Aristotle

      S Offline
      S Offline
      szukuro
      wrote on last edited by
      #2

      Easy way: assign the controls classes and in the CSS use class selectors instead of id selectors Hard way: emit CSS file dynamically using handlers

      T 1 Reply Last reply
      0
      • S szukuro

        Easy way: assign the controls classes and in the CSS use class selectors instead of id selectors Hard way: emit CSS file dynamically using handlers

        T Offline
        T Offline
        theJazzyBrain
        wrote on last edited by
        #3

        Yes, using class selectors is one of the solutions I have already thought. There are cases though when you actually need to use ID selectors. Not many but there are some... :) How about the dynamic CSS emition? Could you please point me to more info about this technique? Thanking you in advance.

        Jason Kataropoulos

        Excellence is not an act, but a habit!

        Aristotle

        S 1 Reply Last reply
        0
        • T theJazzyBrain

          Yes, using class selectors is one of the solutions I have already thought. There are cases though when you actually need to use ID selectors. Not many but there are some... :) How about the dynamic CSS emition? Could you please point me to more info about this technique? Thanking you in advance.

          Jason Kataropoulos

          Excellence is not an act, but a habit!

          Aristotle

          S Offline
          S Offline
          szukuro
          wrote on last edited by
          #4

          theJazzyBrain wrote:

          How about the dynamic CSS emition? Could you please point me to more info about this technique?

          http://www.codeproject.com/useritems/LocalizationHandler.asp[^] Not exactly the same thing, but demonstrates the basic strategy. A simpler, but less elegant solution would be to just use inline CSS, added to the page at runtime as a LiteralControl, in this case you don't need custom handlers.

          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