user1084319
user1084319

Reputation: 299

ResolveUrl doesn't seem to work for ../../ when linking to external javascript files with dynamic virtual directories

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

Answers (1)

Murali Murugesan
Murali Murugesan

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

Related Questions