PostMan
PostMan

Reputation: 6967

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.

Upvotes: 4

Views: 3092

Answers (1)

veggerby
veggerby

Reputation: 9020

If your <head></head> tag contains runat="server" (which IIRC it does by default) you can simply specify it as:

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

Upvotes: 5

Related Questions