1,105,406 Community Members

Running external JavaScript file at ASP Server

Member Avatar
P.manidas
Posting Whiz
309 posts since Oct 2008
Reputation Points: 39 [?]
Q&As Helped to Solve: 15 [?]
Skill Endorsements: 0 [?]
 
0
 

I am trying to run an asp page with an external JavaScript file but it is showing error like this....

Error Type:
Active Server Pages, ASP 0124 (0x80004005)
The required Language attribute of the Script tag is missing.
/ew-ii-as-8/testserverwithEJSF.asp, line 3

My both files are...

TestServerWithEJSF.asp

<html>
<head>
<script type="text/javascript" runat="server" src="EJSF.js"></script>
<%
sub vbproc(num1,num2)
Response.Write(num1*num2);
call jsproc(5,20);
end sub
%>
</head>

<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>

</html>

EJSF.js

function jsproc(num1,num2)
{
Response.Write("<br>Result :");
Response.Write(num1*num2);
}

But, when I run the asp page puting JavaScript codes into the asp page then it is running well in my server as well as clint machine. The codes of the asp page are..

TestServer.asp

<html>
<head>
<%
sub vbproc(num1,num2)
Response.Write(num1*num2)
call jsproc(5,20)
end sub
%>

<script  language="javascript" runat="server">
function jsproc(num1,num2)
{
Response.Write("<br>Result :");
Response.Write(num1*num2);
}
</script>
</head>

<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>

</html>

I am unable to understand how to run the asp page with an external JavaScript file which is running at asp server. Please guide me Sir/Madam.

Member Avatar
vsmash
Junior Poster
138 posts since Feb 2010
Reputation Points: -1 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

Get rid of the runat="server"
add language="javascript"

Member Avatar
P.manidas
Posting Whiz
309 posts since Oct 2008
Reputation Points: 39 [?]
Q&As Helped to Solve: 15 [?]
Skill Endorsements: 0 [?]
 
0
 

Dear Vsmash,

I am sorry, I have not understood, what you mean to say. Could you please explain little more? And have you tried my "TestServerWithEJSF.asp" & "EJSF.js" file's codes?

Thanks.

Member Avatar
vsmash
Junior Poster
138 posts since Feb 2010
Reputation Points: -1 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

Okay so your asp stuff is processed by the server before output but your javascript stuff is not. It is processed by the client browser.

Your vbproc should have no semi colons as line endings and your call to external javascrpt should not have runat="server" and it should have a language specification

TestServerWithEJSF.asp:

<html>
<head>
<script type="text/javascript" language="javascript" src="EJSF.js"></script>
<%
sub vbproc(num1,num2)
Response.Write(num1*num2)
call jsproc(5,20)
end sub
%>
</head>

<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>

</html>

Your external javascript is javascrpt and should have document.write rather than response.write

EJSF.js

function jsproc(num1,num2)
{
document.Write("<br>Result :");
document.Write(num1*num2);
}

If you combine to one page it should look like this:
TestServer.asp

<html>
<head>
<%
sub vbproc(num1,num2)
Response.Write(num1*num2)
call jsproc(5,20)
end sub
%>

<script  language="javascript" type="text/Javascript">
function jsproc(num1,num2)
{
document.Write("<br>Result :");
document.Write(num1*num2);
}
</script>
</head>
Member Avatar
P.manidas
Posting Whiz
309 posts since Oct 2008
Reputation Points: 39 [?]
Q&As Helped to Solve: 15 [?]
Skill Endorsements: 0 [?]
 
0
 

Dear VSMASS,

Thanks for your reply with explanation.

As you have suggested with the file name TestServer.asp, this codes are not working (but as I have mentioned earlier that this file's codes as I have written was working for me) showing error like this...

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'jsproc'
/ew-ii-as-8/TestServerVSMASS.asp, line 6

And suggested with the file name TestServerWithEJSF.asp and EJSF.js, these codes are also not working showing error like this...

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'jsproc'
/ew-ii-as-8/TestServerWithEJSFVSMASS.asp, line 7

But, when I have tested my original codes of "TestServerWithEJSF.asp" file with little modification as below, it is working well in both server and client machine. Only your two suggestion have work for me, one is "semicolon" (this was my mistake) and other is "language specification". But not other suggestions.

<html>
<head>
<script type="text/javascript" [B]language="javascript"[/B] runat="server"  src="EJSF.js"></script>
<%
sub vbproc(num1,num2)
Response.Write(num1*num2)
call jsproc(5,20)
end sub
%>

</head>

<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>

</html>

Javascript file EJSF.js

function jsproc(num1,num2)
{
Response.Write("<br>Result :");
Response.Write(num1*num2);
}

Thanks again, and here I am closing this thread as it has solved my problem.

Question Answered as of 2 Years Ago by vsmash
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: