ASP.NET 2.0 Master Pages – Referencing style sheets

Here’s one of those things I’m always forgetting, and since most of my work is on-site at clients, I don’t have a large source code repository to go back to reference.

To correctly reference a style sheet from within a master page in ASP.NET, use the following:


<link rel="stylesheet" href="<%= ResolveUrl("~/css/screen.css") %>" type="text/css" media="screen, projection" />

It’s the ResolveUrl that does the trick.

Posted on August 25, 2007 in .NET. 1 comment   

One Comment

  1. The Dan said:

    Nothin’ worse than an unresolved URL. Leads to therapy sessions and laminated cards that say something like, “Life is a jouney, and you dropped your plane ticket in Jersey somewhere and, dude, you’re totally screwed now, man, no joke!”

(Comments are moderated.)
 
Welcome !
Site google-analitix.com just created.

Real content coming soon.
© ISPmanager control panel