Onload Event Causing Error in ASP.NET Code

G

Guest

I have the following in my asp.net html page

<script language="JavaScript" type=text/javascript
Function loader()
<% If Not Page.IsPostBack Then %
document.form1.submit()
<% End If %

</script><BODY onLoad="loader();" leftMargin="0" topMargin="0"><form id="form1" runat="server"

When I try to go to that page I get two error: 1) Microsoft Jscript runtime Error Object Expected at the <BODY onLoad="loader();" leftMargin="0" topMargin="0"> lin
2) An Error: Expected ';' at the <script language="JavaScript" type=text/javascript> lin

What's up? It seems like the code is right from all the internet examples I've seen.
 
T

Teemu Keiski

Hi,

"Function" should be "function" (it is all lowercase in JavaScript)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



Bryan said:
I have the following in my asp.net html page:

<script language="JavaScript" type=text/javascript>
Function loader(){
<% If Not Page.IsPostBack Then %>
document.form1.submit();
<% End If %>
}
</script><BODY onLoad="loader();" leftMargin="0" topMargin="0"><form id="form1" runat="server">

When I try to go to that page I get two error: 1) Microsoft Jscript
runtime Error Object Expected at the <BODY onLoad="loader();" leftMargin="0"
topMargin="0"> line
2) An Error: Expected ';' at the <script language="JavaScript" type=text/javascript> line

What's up? It seems like the code is right from all the internet examples
I've seen.
 

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,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top