Avatar of arvee2003
arvee2003
 asked on

ASP-Microsoft JScript runtime error: Object expected.

Hi,

Using vs2008 and c#.

In my development enironment I have 2 website with identical folder structure. And my master pages for
both website are almost similar.

In both the application I have some javascript referenced for counting the number of characters entered as follows:

 <script type="text/javascript" src='<%# Page.ResolveUrl("~/Javascript/textcounter.js") %>'> </script>

It works perfectly fine in one website. However in the other website onkeypress it was trying the javascript function
and it gives the following error.
      Microsoft JScript runtime error: Object expected

I am not sure why it is working on one website and not on the other.

Both VS2008 and the 2 website are all on the same machines.

Looks like it is something specific to a website.

This happens when debugging application using IE. When I ran in Chrome it is not displaying the error.

Is there any issues in webconfig files? All my reference are ok.

It is was working ok 2 days ago and I did not install anything.

Any input is appreciated.

Sure
ASPASP.NET

Avatar of undefined
Last Comment
arvee2003

8/22/2022 - Mon
radcaesar

checl whether u have the js file in ur second website at correct location.
arvee2003

ASKER
Yes. In both the websites I have a folder javascript under my app root directory and it is in there
prajapati84

According to me:

It seems that the JS files are ok, but the page on which it is applied may be missing some element like any id which is used in JS file.

By the way, if you use FIREFOX and FIREBUG addin, it would help you a great. It will provide the exact line in the JS file where the error occurs while applying javascript debugging on. Believe me, it would be the best solution to find out and solve out your problem. It's great tool!

Let me know if you any difficulty.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
arvee2003

ASKER
The code is same in both the websites. It is a problem with IE 8 which was working before
Looks like its unable to resolve the path.

 <script type="text/javascript" src='<%# Page.ResolveUrl("~/Javascript/textcounter.js") %>'> </script>
The above is in master page.

If I look my source code is shows as follows
 <script type="text/javascript" src=''> </script>

Something is messed up in some page. I am not sure where.

But the same thing is in other website on the same machine which works. Are there
website references for javascript or it has something to do with Ajax client

Suresh
arvee2003

ASKER
One more thing. My website root is helpdesk.

If I replace this

 <script type="text/javascript" src='<%# Page.ResolveUrl("~/Javascript/textcounter.js") %>'> </script>

with
<script type="text/javascript" src='/helpdesk/Javascript/textcounter.js") %>'> </script>

it works. No errors

Is there an issue with Page.ResolveUrl method which works in one website and not in other

Suresh
ASKER CERTIFIED SOLUTION
prajapati84

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
prajapati84

<%#
should be
<%=
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
arvee2003

ASKER
It works.