简体   繁体   中英

ASP.NET Root folder of website in CSS

So, I thought I'd try my luck on ASP.NET. I didn't get very far before I found my first problem.

I have a folder layout like so:

\
->Admin
-->Admin.Aspx

->CSS
-->Style.css

->Images
-->bg.gif

Default.aspx
Default.master

Both admin.aspx and default.aspx use the default.master page, which contains the line:

<link rel="stylesheet" type="text/css" href="CSS/Style.css" media="screen" />

This works for the default.aspx page, because the path is valid, but for the admin page it's not.

Is there any special character, like ~ for home in Linux, to indicate the root path? I can't use just a slash, because the website maybe under a sub folder when hosted.

Hopefully I've explained myself so you can understand what I need to do :)

I guess it's more an HTML issue than an ASP issue.

如果您的<head></head>标记包含runat =“server”(默认情况下它是IIRC),您只需将其指定为:

<link rel="stylesheet" type="text/css" href="~/CSS/Style.css" media="screen" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM