开发者

Including CSS in MasterPages

I am new to the domain. I want to include a CSS file in my master pages,but it is not working can anyone try to help me out of this problem..

I give the link to the CSS开发者_运维知识库 externally as

<link href="Stylesheet1.css" rel="Stylesheet1" type="text/css" />

Is there any necessity to include CSS classes in master page if so how and where I have to include?


Try:

<link href="~/Stylesheet1.css" rel="Stylesheet1" type="text/css" />

Tilde (~) represent root directory.

If this doesn't work, if you can show us your directory structure, and look at the rendered source we can help more.


You can of course not use the Tilde (~) on tags that are not run server-side, what you have to do is something like this:

<link href="<%= ResolveClientUrl("~/Stylesheet1.css")%>" rel="stylesheet" type="text/css" />

Or just do a method that gives you back a full link-tag.


There's nothing wrong with the syntax of your <link> tag. The problem is likely to be caused by the fact that your CSS file isn't located at the URL you're attempting to get it from.

The href attribute in your markup specifies a file called Stylesheet1.css in the same folder as your master page. If its not you should specify the location of the stylesheet using standard, virtual path or move the stylesheet to the same folder as your masterpage.

More info.

http://w3schools.com/css/css_howto.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜