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. Keeping my style information in one place

Keeping my style information in one place

Scheduled Pinned Locked Moved ASP.NET
questioncsharpcssasp-net
5 Posts 4 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.
  • J Offline
    J Offline
    jesarg
    wrote on last edited by
    #1

    I have a standards/best practices question for ASP.NET webforms. I'm making a new website that may draw tables onto the page showing reports (depending on user inputs). The style for these tables is in my CSS file. I want to have the header row of a table that I create in the code-behind have a special style, and I can do that by putting style information in the code-behind (with the TableRow.Style.Add() method), but I'd rather pull the information from the CSS file so I only have one place to maintain style elements at. Is there a standard way of doing this?

    E 1 Reply Last reply
    0
    • J jesarg

      I have a standards/best practices question for ASP.NET webforms. I'm making a new website that may draw tables onto the page showing reports (depending on user inputs). The style for these tables is in my CSS file. I want to have the header row of a table that I create in the code-behind have a special style, and I can do that by putting style information in the code-behind (with the TableRow.Style.Add() method), but I'd rather pull the information from the CSS file so I only have one place to maintain style elements at. Is there a standard way of doing this?

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

      Can't you assign CSS classes in the code-behind as well? Instead of tr.Style.Add("font-family", "Verdana") or whatever, you say tr.CssClass = "mySpecialRowStyle"...

      J 1 Reply Last reply
      0
      • E ekolis

        Can't you assign CSS classes in the code-behind as well? Instead of tr.Style.Add("font-family", "Verdana") or whatever, you say tr.CssClass = "mySpecialRowStyle"...

        J Offline
        J Offline
        jesarg
        wrote on last edited by
        #3

        Thanks a lot; I knew there had to be something simple like that.

        J 1 Reply Last reply
        0
        • J jesarg

          Thanks a lot; I knew there had to be something simple like that.

          J Offline
          J Offline
          jkeelerz
          wrote on last edited by
          #4

          Yeah - The use of CssClass as a habit ends up avoiding a ton of headaches - especially as you get into enterprise sized projects with multi-level theming/css..

          Safety Programs: Safe Patient Handling | Hospital Patient Safety Nurse Resources: Nurse Injury Prevention
          | Medical Back Injury Prevention

          J 1 Reply Last reply
          0
          • J jkeelerz

            Yeah - The use of CssClass as a habit ends up avoiding a ton of headaches - especially as you get into enterprise sized projects with multi-level theming/css..

            Safety Programs: Safe Patient Handling | Hospital Patient Safety Nurse Resources: Nurse Injury Prevention
            | Medical Back Injury Prevention

            J Offline
            J Offline
            jerryTheJerry
            wrote on last edited by
            #5

            "as a habit" is an understatement - if you dont stick to only cssclass and try to integrate with ANY other (non .net) code or systems, this will be a nightmare. So, jkeelerz - I couldnt agree more: as a RULE for me though ;)

            By Day: east bay hauling - pleasant hill hauling - moraga junk removal By Night: hack it til I can build it

            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