My JS works when I reference it in the Ma开发者_运维百科sterPage, and it works when I reference it in a Partial View (.ascx
), but not when I reference from the View (.aspx
).
Any ideas why?
Is the path to the script file correct in your View?
If you inspect HTTP traffic with something like Fiddler or Firebug's Net tab, do you see your script resources being downloaded to the browser?
You might want to use UrlHelper.Content
and the relative path to render the script source in the page or perhaps create a HtmlHelper
extension method to render out a script tag for you (I think one exists in MVCContrib if you're using that already).
So if you have a block declared in an included file (let's just pretend it looks like)
function alertMe(someValue) {
alert(somevalue);
}
and in your master page, aspx, and ascx you have
<script type="text/javascript">
alertMe("some string");
</script>
and it works in the master page and the ascx but not the aspx?
精彩评论