views:

15

answers:

1

Hi All:

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???

+1  A: 

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.

Nick Craver
I already include javascript files :<asp:ScriptReference Path="Scripts/JScript.js" />
DEVMBM
@DEVMBM - According to your question, they're rendering as `~/` in the page, is that not the case?
Nick Craver