We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,939 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Running external JavaScript file at ASP Server

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.

2
Contributors
4
Replies
2 Days
Discussion Span
1 Year Ago
Last Updated
5
Views
Question
Answered
P.manidas
Posting Whiz
304 posts since Oct 2008
Reputation Points: 53
Solved Threads: 14
Skill Endorsements: 0

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

vsmash
Junior Poster
125 posts since Feb 2010
Reputation Points: 9
Solved Threads: 17
Skill Endorsements: 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.

P.manidas
Posting Whiz
304 posts since Oct 2008
Reputation Points: 53
Solved Threads: 14
Skill Endorsements: 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>
vsmash
Junior Poster
125 posts since Feb 2010
Reputation Points: 9
Solved Threads: 17
Skill Endorsements: 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.

P.manidas
Posting Whiz
304 posts since Oct 2008
Reputation Points: 53
Solved Threads: 14
Skill Endorsements: 0
Question Answered as of 1 Year Ago by vsmash

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.5402 seconds using 2.75MB