I am building an ASP.NET Webform application with C # in VS 2012, .NET framework 4.5
I have MasterPage in the root of the application, the JavaScript files are in a folder called js.
Here's the problem: If the page is in the root folder , then everything works fine (css + js), if I put any pages in a subfolder , then css works, but these JavaScripts do n't work at all , obviously the link path is wrong.
So, the Css link path is fine, but for the script no matter what I used, they all don't work (js / script.js or ~ / js / script.js or / js / script.js or ../ ResolveUrl, ResolClientveUrl ... or the whole method in this http://yobriefca.se/blog/2010/10/19/%3C-head-%3Eache-including-javascript-in-asp-dot-net-master-pages/ ), they all refer to root / SUB-FOLDER / js / script.js instead of root / js / script.js
at the root: one MasterPage folder, Default.aspx, test.aspx, js, css folder and Pages folder. By default, test pages are also a working file, but all pages in the Pages folder are not displayed .js SO OBLIVIOUSLY the path is incorrect if the pages are not in the root
On my main page:
<head runat="server"> <title></title> <link rel="stylesheet" href="~/css/style.css" /> <%-- tried these and lot more but NOT workkkkkkkkkkk --%> <%--<script src="~/js/jquery-1.7.1.min.js" ></script> <script src="~/js/script.js" ></script>--%> <%--<script src='<%=ResolveUrl("~/js/jquery-1.7.1.min.js") %>' ></script> <script src='<%=ResolveUrl("~/js/script.js") %>' type="text/javascript"></script>--%> <%--<script src='<%=ResolveClientUrl("~/js/jquery-1.7.1.min.js") %>' type="text/javascript"></script> <script src='<%=ResolveClientUrl("~/js/script.js") %>' type="text/javascript"></script>--%> <asp:ContentPlaceHolder ID="Head" runat="server"> </asp:ContentPlaceHolder>
script.js has something like:
.... $.include('js/superfish.js') $.include('js/FF-cash.js') $.include('js/tms-0.4.x.js') $.include('js/uCarausel.js') $.include('js/jquery.easing.1.3.js') $.include('js/jquery.tools.min.js') $.include('js/jquery.jqtransform.js') $.include('js/jquery.quicksand.js') $.include('js/jquery.snippet.min.js') $.include('js/jquery-ui-1.8.17.custom.min.js') $.include('js/jquery.cycle.all.min.js') $.include('js/jquery.cookie.js') $(function(){ if($('.tweet').length)$.include('js/jquery.tweet.js'); if($('.lightbox-image').length)$.include('js/jquery.prettyPhoto.js'); if($('#contact-form').length||$('#contact-form2').length)$.include('js/forms.js'); if($('.kwicks').length)$.include('js/kwicks-1.5.1.pack.js'); if($('#counter').length)$.include('js/jquery.countdown.js'); if($('.fixedtip').length||$('.clicktip').length||$('.normaltip').length)$.include('js/jquery.atooltip.pack.js') // Slider $('.main-slider')._TMS({ .....
ERROR in the developer tool (Console) of a web browser:
Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/tms-0.4.x.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/uCarausel.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery.jqtransform.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery.quicksand.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery.snippet.min.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/FF-cash.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/superfish.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery.tools.min.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery-ui-1.8.17.custom.min.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery.cycle.all.min.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery.easing.1.3.js Failed to load resource: the server responded with a status of 404 (Not Found) http://ApplicationRoot/Pages/js/jquery.cookie.js Uncaught TypeError: Object [object Object] has no method '_TMS' script.js:22 event.returnValue is deprecated. Please use the standard event.preventDefault() instead.