Resolve URL paths

When using MasterPages, Cascading Style Sheets (CSS) and JavaScript files it is quite hard to keep track of all URL paths. Rather than changing the path for each page when referencing the CSS file or any other file which is located in different paths, the ResolveURL can be used. Below are quick examples on how each can be used:


<link href=”<%= ResolveUrl(“~/”) %>cssFolder/myStyle.css” rel=”stylesheet” type=”text/css” />

style on html / aspx page:

<div style="background:url('<%= ResolveUrl("~/myImages/myFavImage.jpg") %>') repeat;"> </div>


<script type=”text/javascript” src=”<%= ResolveUrl(“~/”) %>js/jquery.min.js”></script>

Dynamic URL using jQuery FancyBox:

<a href=”#” onclick=”$.fancybox({‘href’ : ‘<%= ResolveUrl(“~/”) %>myFolder/myPage.html’,’type’:’iframe’,’width’: 900,’height’: 500});return false;”>My Page</a>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s