Reputation: 10991
I'm creating usercontrol. This control use javascript
<script src='js/my.js' type='text/javascript'></script>
My web directory location is here>>
App_code\myusercontrol.css
User\aa.aspx
bb.aspx
aa.aspx
And bb.aspx
is use my created usercontrol.
My problem is
when i calling aa.aspx
, successfully work
when i calling bb.aspx
, javascript location error
I'm changing script to <script src='../js/my.js' type='text/javascript'></script>
when i calling bb.aspx
, successfully work
when i calling aa.aspx
, javascript location error
How to fix this problem?
Upvotes: 2
Views: 91
Reputation: 82355
You can specify an absolute path to the script IE:
<script src='/js/my.js' type='text/javascript'></script>
Or you can resolve the URL dynamically through asp...
<script src='<%=ResolveUrl("~/js/my.js")%>' type='text/javascript'></script>
Upvotes: 6