ASP.NEt with JS Files

D

Dessip

Hey,

I'v had this problem for a while and I don't know why its not working.

If i place script in the ASP Page (HTML Section) then it works fine,
thou if i try to refrence a JS file, it wont work.

I have tried using <Script src="JavaScriptFile"
Type="text/Javascript"></script> in the head, but I had no joy, thou if
I include the JavaScript in <script> brackets, it works fine, I have
also tried it with alert and the same happens, no matter what I try and
do, the java will only work when its in the page, otherwise I get the
error Object Expected.

The test code I have been trying is:

<html>
<head>
<Script src="bin/Test.js" type="text/javascript"></script>
</head>
<body onLoad="testFunction();">
</body>
</html>

and test function is:

function testFunction()
{
alert('test');
}

thanks for any help.

I am developing with ASP.NET V1.1
 
R

Rob Meade

...
<Script src="bin/Test.js" type="text/javascript"></script>

Unless you've changed the permissions, I'm not entirely sure you'll find
that the IUSR_Machine name account has permissions to access the /bin
directory.

..Net uses a separate processor account hence being able to access it. Try
moving the script file out to the root directory of your website, and then
change your src= attribute to match.

Regards

Rob
 
T

tfsmag

have you tried putting it in directory besides 'bin'? I always put my
js in a 'js' directory, I'd also try adjusting the path to be the
complete path from the root directory. ie:
/appfolder/js/javascriptfile.js
 
D

Dessip

Hey,

Yeh i have tried that, cause i thought of permissions, but still
nothing, i ahve tryed it in 3 different lcoations, the root, Bin, and
also a folder called JS but still nothing.

im servearly at a loss here.

Short of includeing ethe javascript in all of the HTML pages, and
having to mod every one of them, and bulk them out with javaScript i
aint got a clue.

Regards
Chris

Eliyahu said:
Is the file in "bin" folder or in the root one?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

Dessip said:
Hey,

I'v had this problem for a while and I don't know why its not working.

If i place script in the ASP Page (HTML Section) then it works fine,
thou if i try to refrence a JS file, it wont work.

I have tried using <Script src="JavaScriptFile"
Type="text/Javascript"></script> in the head, but I had no joy, thou if
I include the JavaScript in <script> brackets, it works fine, I have
also tried it with alert and the same happens, no matter what I try and
do, the java will only work when its in the page, otherwise I get the
error Object Expected.

The test code I have been trying is:

<html>
<head>
<Script src="bin/Test.js" type="text/javascript"></script>
</head>
<body onLoad="testFunction();">
</body>
</html>

and test function is:

function testFunction()
{
alert('test');
}

thanks for any help.

I am developing with ASP.NET V1.1
 
R

Rob Meade

...
Yeh i have tried that, cause i thought of permissions, but still
nothing, i ahve tryed it in 3 different lcoations, the root, Bin, and
also a folder called JS but still nothing.

hmmm..odd...

Isn't there a "language" attribute for that script tag too?

ie,

<script src="test.js" type="text/javascript" language="javascript">

not sure if that might make any difference?

There's definately no problems in the test.js file is there? Maybe
something in there that would prevent it from loading/erroring or something?

Rob
 
R

Ray Booysen

The language isn't required, only type

Rob said:
...


hmmm..odd...

Isn't there a "language" attribute for that script tag too?

ie,

<script src="test.js" type="text/javascript" language="javascript">

not sure if that might make any difference?

There's definately no problems in the test.js file is there? Maybe
something in there that would prevent it from loading/erroring or something?

Rob
 
D

Dessip

I have tried it with and without language, no diff.

As for the JS file, i ahve also tried it with jsut that one function on
there, and still nothing.

I dont knwo why its not loading the JS file in, but no matter where i
put it, ill always get a error to do with the JS File (Object Expected)
 
D

Dessip

Im gong to try re-creating the project.
if not re-install the IIS, if not i aint got a clue.
 
D

Dessip

Hello,

I have re-created the Virtual Directory like i said then I changed the
name of the JS file, and included it in the same directory like you
surgested,
And then it ran fine.

Thank you for your help.
Regards
Chris

Eliyahu said:
Ok, just make a clean experiment. Leave the .js file in the same directory
with the .aspx file and delete it from all other locations. Refer to it as
<Script src="Test.js" type="text/javascript"></script>

Make sure there are no caching issues involved. For this, add an extra space
to both .aspx and .js files and save them to ensure the latest file
modification timestamp.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

Dessip said:
Hey,

Yeh i have tried that, cause i thought of permissions, but still
nothing, i ahve tryed it in 3 different lcoations, the root, Bin, and
also a folder called JS but still nothing.

im servearly at a loss here.

Short of includeing ethe javascript in all of the HTML pages, and
having to mod every one of them, and bulk them out with javaScript i
aint got a clue.

Regards
Chris

Eliyahu said:
Is the file in "bin" folder or in the root one?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

Hey,

I'v had this problem for a while and I don't know why its not working.

If i place script in the ASP Page (HTML Section) then it works fine,
thou if i try to refrence a JS file, it wont work.

I have tried using <Script src="JavaScriptFile"
Type="text/Javascript"></script> in the head, but I had no joy, thou if
I include the JavaScript in <script> brackets, it works fine, I have
also tried it with alert and the same happens, no matter what I try and
do, the java will only work when its in the page, otherwise I get the
error Object Expected.

The test code I have been trying is:

<html>
<head>
<Script src="bin/Test.js" type="text/javascript"></script>
</head>
<body onLoad="testFunction();">
</body>
</html>

and test function is:

function testFunction()
{
alert('test');
}

thanks for any help.

I am developing with ASP.NET V1.1
 
E

Eliyahu Goldin

Ok, just make a clean experiment. Leave the .js file in the same directory
with the .aspx file and delete it from all other locations. Refer to it as
<Script src="Test.js" type="text/javascript"></script>

Make sure there are no caching issues involved. For this, add an extra space
to both .aspx and .js files and save them to ensure the latest file
modification timestamp.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

Dessip said:
Hey,

Yeh i have tried that, cause i thought of permissions, but still
nothing, i ahve tryed it in 3 different lcoations, the root, Bin, and
also a folder called JS but still nothing.

im servearly at a loss here.

Short of includeing ethe javascript in all of the HTML pages, and
having to mod every one of them, and bulk them out with javaScript i
aint got a clue.

Regards
Chris

Eliyahu said:
Is the file in "bin" folder or in the root one?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

Dessip said:
Hey,

I'v had this problem for a while and I don't know why its not working.

If i place script in the ASP Page (HTML Section) then it works fine,
thou if i try to refrence a JS file, it wont work.

I have tried using <Script src="JavaScriptFile"
Type="text/Javascript"></script> in the head, but I had no joy, thou if
I include the JavaScript in <script> brackets, it works fine, I have
also tried it with alert and the same happens, no matter what I try and
do, the java will only work when its in the page, otherwise I get the
error Object Expected.

The test code I have been trying is:

<html>
<head>
<Script src="bin/Test.js" type="text/javascript"></script>
</head>
<body onLoad="testFunction();">
</body>
</html>

and test function is:

function testFunction()
{
alert('test');
}

thanks for any help.

I am developing with ASP.NET V1.1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top