I usually refer a jQuery using:
<script src='@(Url.Content("~/JavaScript/jquery.maskedinput-1.2.2.js"))' type="text/javascript"></script>
I refer the same Jquery in many Pages. Any change to the static content (name or version number) requires that all views are updated to absorb the change.In order to solve this I tried creating routes in Global.asax for Jquery file like below
routes.MapRoute("jquery.maskedinput.js", "Javascript/jquery.maskedinput-1.2.2.js");
and i tried to call it in cshtml using a Html Helper like below
<script src='@Html.RouteLink("maskedinput","jquery.maskedinput.js") ' type="text/javascript"></script>
I know RouteLink returns a Anchor tag and so the Source is not rightly set for the Jquery to load.
Requirements:
- Is there any other Html helper which can return only the virtual
path (or) - I need to reference Jquery with a name not with a path. The path
should be declared somewhere globally so that a single change in the
global file can solve the purpose.
Help me, please.
I use this method for my
BundleCollectionwithSystem.Web.Optimizationsee my question, but this still works even with out it.then use it like this:
which renders
Note that this requires a reference in your view to
PROJECT.Classesor wherever you put it. I’ve got that setup in myweb.configin the views folder.