ASP.NET declare a CSS stylesheet one time only
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 for开发者_如何转开发ced to use a .master page? or is there another way to do this..
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
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).
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)
精彩评论