Error: Microsoft JScript runtime error: Object expected

I am attempting to learn C# by using an example shown in "Beggining Visual Web rogramming in C#" by Daniel Calzzulino etc.  The example displays the time based on the Web server. When a button is clicked, the Client time is displayed.

This all works well until I click the button that is designed to display the Client time. I get the
Microsoft JScript runtime error: Object expected error on the folllowing line:
    <input onclick ="Alert('Web Client time is now ' + new Date());"
        type=button value="Client Time" />
What did I do wrong?

Here is the code:

Webform1.aspx

<%@ Page Language="C#" CodeBehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="ClockExample.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>What Time is it</title>
    <meta name="CODE_LANGUAGE" content = "C#" />
    <meta name="vs_defaultClientScript" content = "JavaScript" />
    <meta name="vs_targetSchema" content = "http://schemas.microsoft.com/intellisence/ie5" />
</head>
<body MS_Positioning="GridLayout>
    <form id="form1" method=post runat="server">
    <p> The time (According to the Web Server) is:
        <%=System.DateTime.Now %>
    </p>
    <p> What is the time on the Web Client?
        <input onclick ="Alert('Web Client time is now ' + new Date());"
        type=button value="Client Time" />
    </p>
    </form>
</body>
</html>

Webform1.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace ClockExample
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="ClockExample._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>
</html>

Thanks,




DovbermanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DovbermanAuthor Commented:
I found the error:

The alert object should be referenced as window.alert

    <input onclick= "window.alert('Web Client time is now ' + new Date());"
        type=button value="Client Time" />

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.