I'd like in an .cshtml
page, insert an .js
page.
I tried this :
<script src="@Url.Content("~/Scripts/MyFile.js")" type="text/javascript"></script>
No problem with the same code in the shared/_layout.cshtml
(in the header section)
When I execute the application, this file is not present in the source code (not include).
Any idea ?
Thanks,
I'd like in an .cshtml
page, insert an .js
page.
I tried this :
<script src="@Url.Content("~/Scripts/MyFile.js")" type="text/javascript"></script>
No problem with the same code in the shared/_layout.cshtml
(in the header section)
When I execute the application, this file is not present in the source code (not include).
Any idea ?
Thanks,
Share Improve this question asked Feb 12, 2012 at 15:22 TheBoubouTheBoubou 20k54 gold badges151 silver badges250 bronze badges 3- What's the response httpCode? Look using a web developer tool like Firebug in Firefox or Developer Tool in Chrome. – Acaz Souza Commented Feb 12, 2012 at 15:25
- Is the script block included in your source code? – Martijn Commented Feb 12, 2012 at 15:28
- The response is correct but the js is not in – TheBoubou Commented Feb 12, 2012 at 15:36
2 Answers
Reset to default 1try:
<script src="@Url.Content("../../Scripts/MyFile.js")" type="text/javascript"></script>
Your code is correct (assuming you are using Razor templating in MVC3). The only way this would not work is if the path to your script is wrong.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745492160a4630033.html
评论列表(0条)