Using ResolveUrl to correct paths in html controls

Just a quick post. When i'm working on my development server and debug locally I run into issues on html controls and paths.  Such as: http://localhost:9999/YourVirtualDirectory/

The directory does not really exist so when the dom objects access paths like this, they won't work

<script type="text/javascript" src="~/Scripts/jquery.lavalamp.js"></script>

Neither will this

<script type="text/javascript" src="../Scripts/jquery.lavalamp.js"></script>

But this will

<script type="text/javascript" src='<%= ResolveUrl("~/Scripts/jquery.lavalamp.js") %>'></script>


So there ya have it. Use the ResolveUrl method to fix those pesky paths once and for all and not have to change it prior to moving to production.

Happy Coding..
Merlin

Comments

Popular posts from this blog

Why Windows User Profiles Break: AI Confirms Long‑Standing UI Flaws

How to Ask AI the Right Questions: A Forensic Guide to Context, Ambiguity, and Guardrails

Microsoft Breaks Decades‑Old Configuration Hierarchy in Visual Studio 2026