Skip to content
Donner's Daily Dose of Drama
Donner's Daily Dose of Drama
  • The Good
    • Blogging
    • Consumer Protection
    • Environment
    • Ethics
    • Geek’s Home
    • Lisa Lanett
    • Medfield
    • Music
    • Parenting and Technology
    • Travel
    • wow
  • The Bad
    • Business
    • Ebay
    • Investment
    • Job search
    • Personal Finance
    • Politics
  • The Ugly
    • Information Technology
      • Business Intelligence
      • Content Management
      • Free Software
      • I18N and L10N
      • Java
      • Open Source
      • Mobile Devices
      • Open Source Business Intelligence
      • OSBI
      • SDA
      • Security
      • Smartphone
      • Software Best Practices
      • Software Engineering
      • SQL Server
      • Streaming Media
      • Web
    • Austria
    • Fiction
    • Hardware
    • iPod
    • Miscellaneous
    • Uncategorized
    • Video
    • Weekend Warrior
Donner's Daily Dose of Drama

ASP.Net MasterPage: How to use the page name in CSS skinning

Christian Donner, July 6, 2011January 12, 2013

Sometimes it can be convenient to create CSS styles that are unique to a specific page context, either because a page requires a special rule or override due to its features, or because some style rule must be applied based on the page context.

I have used this for instance in Drupal skinning when a certain color identifies the page, and rules for header font colors are created specific to pages. How can such a class id be generated “automatically” in ASP.Net, without hardcoding the page name into the markup (or, if a Masterpage is used, into the code-behind)?

Simple. My MasterPage markup contains the following:

<body class="<% = System.IO.Path.GetFileNameWithoutExtension(Request.PhysicalPath)%>"></body>

Assuming that I have a page named index.aspx, I now can create CSS rules that only apply to this page:

body.index div.title { color: #f00; }

Related Posts:

  • OpenVPN
  • TyreWiz not working after battery change
  • Enphase Envoy Local Access
  • SUTAB Scam?
  • Amazon threatens customer of 26 years

Information Technology ASP.Netcssskinning

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Pages

  • About
  • Awards
    • TechnoLawyer
  • Contact Christian Donner
  • Project Portfolio
  • Publications
  • Speaking Engagements

Recent Comments

  • Christian Donner on Sealing a leaky cast-iron fireplace chimney damper
  • Eric on Sealing a leaky cast-iron fireplace chimney damper
  • Christian Donner on Contact Christian Donner
  • Max on Contact Christian Donner
  • Christian Donner on Contact Christian Donner

Tags

AHCI Amazon Android ASP.Net AT&T Droid Drupal email Error failure featured firmware Garmin Godaddy Google honda Internet Explorer 8 iPhone Lenovo Lisa Lanett Modules NAS Nexus One Paypal Performance Privacy QNAP raid RS-407 sauna Security spam SQL SR3600 Synology T-Mobile T430s transmission tylö Verizon Virus VMWare Windows 7 windows 8.1 Windows Mobile
  • About
  • Awards
    • TechnoLawyer
  • Contact Christian Donner
  • Project Portfolio
  • Publications
  • Speaking Engagements
©2025 Donner's Daily Dose of Drama | WordPress Theme by SuperbThemes