errors when loading my .js external file

F

FBro

Source code:
Line 11: {
Line 12: oForm.requiredemail.className='backclrPink';
Line 13: alert("The e-mail address you entered is not valid. Please
re-enter your e-mail. The format should be like (e-mail address removed)
(or .net, or .org, etc.)");

Error message:
Compiler Error Message: JS1135: Variable 'alert' has not been
declared

Clicking on Show Detailed Compiler Output:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
\root\6227d372\8fa8293\App_Code.1g3nc3r1.1.js(11,12) : error JS1135:
Variable 'System' has not been declared
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
\root\6227d372\8fa8293\App_Code.1g3nc3r1.1.js(11,12) : error JS1146:
Unknown custom attribute class or constructor
d:\hosting\bro2000az\App_Code\formValid.js(13,3) : error JS1135:
Variable 'alert' has not been declared
d:\hosting\bro2000az\App_Code\formValid.js(85,22) : warning JS1187:
Variable 'tempobj' might not be initialized
d:\hosting\bro2000az\App_Code\formValid.js(86,9) : warning JS1187:
Variable 'tempobj' might not be initialized
d:\hosting\bro2000az\App_Code\formValid.js(2,1) : error JS1234: Only
type and package definitions are allowed inside a library


My request is for someone to help me solve the problem indicated
above.
When I run this using IIS on my computer I do not get this error.
"formValid.js" is where all of the javascript is located. It is
referenced on the .aspx page like this:
<script type="text/javascript" src="..\App_Code\formValid.js"/>

Thank you for any help you offer.
Fred
 
V

VK

Source code:
Line 11: {
Line 12: oForm.requiredemail.className='backclrPink';
Line 13: alert("The e-mail address you entered is not valid. Please
re-enter your e-mail. The format should be like (e-mail address removed)
(or .net, or .org, etc.)");

Error message:
Compiler Error Message: JS1135: Variable 'alert' has not been
declared

alert, confirm, prompt are not native Javascript methods: they are
methods of window host object so they really are window.alert,
window.confirm, window.prompt
It is just common yet not suggested shortcut to use them without
indicating the parent object. If there is not window, then where is
not such methods as you may guess.
To pass over Visual Studio compilation you may add at the beginning of
your file something like:

if (typeof alert == 'undefined') {
var alert : new Function;
var confirm : new Function;
var prompt : new Function;
var window = {
'alert' : alert;
'confirm' : confirm;
'prompt' : prompt;
}
}
 
T

Thomas 'PointedEars' Lahn

FBro said:
Source code:
Line 11: {
Line 12: oForm.requiredemail.className='backclrPink';
Line 13: alert("The e-mail address you entered is not valid. Please
re-enter your e-mail. The format should be like (e-mail address removed)
(or .net, or .org, etc.)");

Error message:
Compiler Error Message: JS1135: Variable 'alert' has not been
declared

Sigh. [psf 10.1]

`alert' is a method of a host-defined property (`window') of the Global
Object that is available client-side only. ASP .NET is server-side.

You are the second person this week to ask such a question. Please search
before you post.
When I run this using IIS on my computer I do not get this error.
"formValid.js" is where all of the javascript is located. It is
referenced on the .aspx page like this:
<script type="text/javascript" src="..\App_Code\formValid.js"/>

http://validator.w3.org/ applied to the response probably shows why that is
wrong.

Why do people have to mess around with things before they got the basics?
Has an ASP .NET class started recently?


PointedEars
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top