0

I Have usercontrol and i registered the following javascript method in code behind :

changeSelectedMenu(controlID);

the previous method is declared in JScript.js file so i registered it also .

but the following exception has been thrown :

 Microsoft JScript runtime error: Object expected

The result page is :

<script src="~/Scripts/JQuery.js" type="text/javascript"></script>
<script src="~/Scripts/JScript.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
changeSelectedMenu('ctl00_ctl00_cntMain_procedureContentHolder_procedureMenu_appointmentsLink');//]]>
</script>

Is There anyone can help me to workaround this issue???

DEVMBM
  • 492
  • 1
  • 5
  • 17

1 Answers1

1

These aren't valid paths to your JavaScript:

<script src="~/Scripts/JQuery.js" type="text/javascript"></script>
<script src="~/Scripts/JScript.js" type="text/javascript"></script>

They need to be relative to the page or to the site root, for example:

<script src="/Scripts/JQuery.js" type="text/javascript"></script>
<script src="/Scripts/JScript.js" type="text/javascript"></script>

While ~/ works for resolving a path on the server-side, the browser doesn't know how to handle this. There are some other work-arounds in this question for making it work and still being app-relative.

Community
  • 1
  • 1
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155