views:

33

answers:

1

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?

+6  A: 

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>
Quintin Robinson
Thank you. That's very helpful. I love stackoverflow and greet programming experts.
ebattulga