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>