In an aspx page you can't include the runat=”server” attribute for a script file.

Problem:

<script src=”~/scripts/jsfile.js” type=”text/javascript”><script>

Including the runat=”server” attribute will produce a compilation error on the page. A work around to this issue is to use the ResolveUrl() method.

Solution:

<script src=”<%ResolveUrl(”~/scripts/jsfile.js”)%>” type=”text/javascript”></script>

Utilizing the ResolveUrl() method will replace the instance of ~ in the string with the value of the application’s path; thus, providing the same benefit that runat=”server” gives you in style sheet links and image tags.