HTML HREF, how to set relative path from the root (without using ".." to move up)?
12,948
You should be able to use Page.ResolveUrl:
<link href="<%= Page.ResolveUrl("~/Css/StyleSheet.css") %>" rel="stylesheet" type="text/css" />
Or possibly turn it into server control and be able to use the tilde:
<link href="~/Css/StyleSheet.css" runat="server">
Author by
J - C Sharper
Updated on June 09, 2022Comments
-
J - C Sharper almost 2 years
For Example, if I have this in my aspx file:
<link href="../Css/StyleSheet.css" rel="stylesheet" type="text/css" />
with ".." indicate to go up one directory level.
Whenever I move the aspx page to different directory level, I have to set it again. How do I set it so that it will be relative to the root of the project folder? (So that either if I move the project folder to somewhere else and/or moving the aspx page to upper/lower directory level, I won't have to set it again?