webforms - Path translation in asp.net masterpage -


in site.master page, have references few css , js files. when page in subfolder uses master page, can see css file's path gets correctly translated, adding necessary ../ in front of it, not js files results in 404 errors when viewed in chrome's debug window.

i tired using ~ runat=server force translation; didn't work; tried using page.resolveurl gives no error message seems break script , not sure how can work.

in site.master:

<!-- bootstrap core css --> <link href="assets/css/bootstrap.min.css" rel="stylesheet" /> 

this gets correctly displayed following .aspx page in sub-folder:

<link href="../assets/css/bootstrap.min.css" rel="stylesheet" /> 

for js files, none of following works.

this 1 shows same file in sub-folder:

<!-- bootstrap core javascript --> <script src="assets/scripts/bootstrap.min.js"></script> 

this 1 shows no 404 erro; "/<sitename>/" gets prepended path script not work (e.g. drop down menu not drop)

<!-- bootstrap core javascript --> <script src='<%= page.resolveurl("~/assets/scripts/bootstrap.min.js") %>'></script> 

and one, don't think can this!

<!-- bootstrap core javascript --> <script runat="server" src="~/assets/scripts/bootstrap.min.js"></script> 

i found answer here. post offers few options listed edit2 of answer worked me:

<!-- jquery --> <script type="text/javascript" src='<%= page.resolveclienturl("~/assets/scripts/jquery.js") %>' ></script>  <!-- bootstrap core javascript --> <script type="text/javascript" src='<%= page.resolveclienturl("~/assets/scripts/bootstrap.min.js") %>' ></script> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -