admin管理员组文章数量:1312646
I have asp usercontrol that is including some js script like this
<script type="text/javascript" language="javascript" src="../JScripts/JScripts.js"/>
The problem is that when I am using this usercontrol in some pages, it works correctly, but when using some pages in another folder structure, it fails with the file not found exception message. Changing js path to
~/JScripts/JScripts.js
doesn't help. is there any way to solve this problem decoratively?
I have asp usercontrol that is including some js script like this
<script type="text/javascript" language="javascript" src="../JScripts/JScripts.js"/>
The problem is that when I am using this usercontrol in some pages, it works correctly, but when using some pages in another folder structure, it fails with the file not found exception message. Changing js path to
~/JScripts/JScripts.js
doesn't help. is there any way to solve this problem decoratively?
Share Improve this question edited Jun 23, 2011 at 15:24 Muhammad Akhtar 52.2k37 gold badges139 silver badges191 bronze badges asked Nov 26, 2009 at 9:18 Arsen MkrtchyanArsen Mkrtchyan 50.8k33 gold badges154 silver badges187 bronze badges 1- have you tried my solution? it will defintly work. – Muhammad Akhtar Commented Nov 26, 2009 at 9:36
4 Answers
Reset to default 7EDITED:
you always have the option of doing something like this:
<script type="text/javascript" language="javascript" src="<%= ResolveClientUrl("~/JScripts/JScripts.js") %>" />
you could try ResolveUrl this like...
Page.ClientScript.RegisterClientScriptInclude("JScripts", ResolveUrl("~/JScripts/JScripts.js"));
Have you considered specifying path from root?
src="/JScrips/JScripts.js"
How about:
<script type="text/javascript" language="javascript" src="/JScripts/JScripts.js"/>
(use the absolute path from the root of your app)
本文标签: javascriptRelative script path in usercontrolStack Overflow
版权声明:本文标题:javascript - Relative script path in usercontrol - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741916003a2404734.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论