senzacionale
senzacionale

Reputation: 20916

aspx ~ problem with JS

why in aspx ~ not working when i try to use it in JS

<script type="text/javascript" src="~/js/jQuery/jquery-ui.min.1.7.3.js"></script> 

in source code is the same ~/js

but with CSS works

<link href="~/css/confirm.css" rel="stylesheet" type="text/css" media="screen" />

Upvotes: 0

Views: 87

Answers (2)

angularconsulting.au
angularconsulting.au

Reputation: 28309

"~/" -substitution for the application root in ASP.NET, should work only with ASP.NET server controls

For example in ASP.NET MVC you may go like that:

<link href="@Url.Content("~/Content/Css/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Content/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>

You can view method Url.Content (System.Web.Mvc.dll, v4.0.30319, class UrlHelper) in Reflector.

Or you may try like that:

<link href="/Content/Css/Site.css" rel="stylesheet" type="text/css" />
<script src="/Content/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>

Upvotes: 1

MartinHN
MartinHN

Reputation: 19782

~ only works for server controls, AFAIK. Don't know why it works for your CSS include.

Upvotes: 1

Related Questions