日期:2014-05-19  浏览次数:20459 次

才学AJAX,问个简单问题,希望大家帮我看看,谢谢!
我用VS2005把一本书上的AJAX代码照抄了一边,但是报错~能告诉我怎么修改一下么?代码如下
Default.aspx
------------------------
<%@   Page   Language= "C# "   AutoEventWireup= "true "     CodeFile= "Default.aspx.cs "   Inherits= "_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> 无标题页 </title>
       
        <script   language= "javascript "   type= "text/javascript "   src= "lookup.js "> </script>
<script   language= "jscript "   type   = "text/javascript ">

mainLoop   =   function()
{
val   =   escape(queryField.value);
if   (lastVal   !=   val)
{
var   response   =this.GetSearchItems(val);
showQueryDiv(response.value);
lastVal   =   val;
}
setTimeout( 'mainLoop() ',   100);
return   true;
}
</script>

</head>
<body   onload= "javascript:InitQueryCode( 'TextBox1 ') ">
        <form   id= "form1 "   runat= "server ">
        <div   style= "text-align:   center ">
                <asp:TextBox   ID= "TextBox1 "   runat= "server "> </asp:TextBox> </div>
        </form>
</body>
</html>


Default.aspx.cs
---------------------------------
using   System;
using   System.Data;
using   System.Configuration;
using   System.Collections;
using   System.ComponentModel;
using   System.Drawing;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;
using   System.Data.SqlClient;
using   AjaxPro;

public   partial   class   _Default   :   System.Web.UI.Page  
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                Utility.RegisterTypeForAjax(typeof(_Default));
        }

        [AjaxMethod()]
        public   ArrayList   GetSearchItems(string   query)
        {
                ArrayList   items   =   new   ArrayList();

                string   myConnectionString   =
                        "Data   Source=localhost;user   id=sa;password=;initial   catalog=pubs &