views:

101

answers:

3

Hi, if i have a single CSS stylesheet for a website and only want to declare it once, that is, not use the following code on every aspx page..

<link href="stylesheets/general.css" rel="stylesheet" type="text/css" />

Am i forced to use a .master page? or is there another way to do this..

A: 

You can use a base page that all your pages inherit from and load it in that. Other than that there's probably a way of doing something by hooking into the pipeline. (Example of this last approach here http://www.4guysfromrolla.com/articles/120308-1.aspx)

Martin Smith
+1  A: 

Master pages are you best bet here. I would guess that once you get that in there, before long you'll find lots of other great things to put in there, too.

There are other solutions, but they're not as easy (e.g. subclass page and inject scripts).

Michael Haren
I agree. Even if there is no design element to it just having a place holder in the head for common scripts and style sheets is tremendously useful.
Martin Smith
+2  A: 

in addition to what was mentioned above, use an ASP.Net theme with the CSS in it. The master page will have the css file included automatically.

http://odetocode.com/articles/423.aspx

Raj Kaimal