1

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..

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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).

1 Comment

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.
0

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 https://web.archive.org/web/20211029043851/https://www.4guysfromrolla.com/articles/120308-1.aspx)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.