Reputation: 299
so I've had this problem before. since the virtual directory is dynamic it keeps breaking my javascript links. I used ResolveUrl for them and it seemed to have worked.(this is in an .aspx file)
<link href="<%=ResolveUrl("~/JQueryPlugins/Tooltip/toolitp.css")%>" rel="stylesheet" type="text/css" />
however, I have ran into a problem. In another file I have another bunch of javascript links that link to javascript files 2 directories up, so the default would look like :
<script type="text/javascript" src="../../lib/yui/utilities/utilities.js"></script>
the ../../ seems to be messing up resolveUrl so it still cant find the files.
Upvotes: 0
Views: 303
Reputation: 22619
Write some utility function to detect the root path and append with it.
Ex: GetAppPath()+"/lib/yui/utilities/utilities.js";
public static string GetAppPath() {
return (System.Web.HttpRuntime.AppDomainAppVirtualPath == "/") ? string.Empty : System.Web.HttpRuntime.AppDomainAppVirtualPath;
}
Upvotes: 1