Skip to content

Instantly share code, notes, and snippets.

@samandmoore
Created June 18, 2011 18:38
Show Gist options
  • Save samandmoore/1033385 to your computer and use it in GitHub Desktop.
Save samandmoore/1033385 to your computer and use it in GitHub Desktop.
script helper in app_code
@using System.Web.Mvc;
@helper Script(string scriptName, UrlHelper url) {
<script type="text/javascript" src="@url.Content("~/Scripts/" + scriptName)"></script>
}
example extracted from:
http://www.pluralsight-training.net/microsoft/players/PSODPlayer.aspx?author=scott-allen&name=mvc3-building-ajax&mode=live&clip=0&course=aspdotnet-mvc3-intro
he explains the reasoning for passing in the reference to @Url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment