请各位大虾帮忙看一下我的AutoCompleteExtender为什么不能用
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AutoCompleteExtend.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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>
<style type="text/css">
.style2
{
height: 50px;
}
.style3
{
width: 180px;
height: 50px;
}
.style4
{
height: 20px;
}
.style5
{
width: 180px;
height: 20px;
}
.style6
{
height: 65px;
}
.style7
{
width: 180px;
height: 65px;
}
.style8
{
height: 20px;
width: 636px;
}
.style9
{
height: 50px;
width: 636px;
}
.style10
{
height: 65px;
width: 636px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div runat="server">
<table style="background-image: url('Images/index-top.jpg'); height: 135px; width: 1024px;"
runat="server">
<tr>
<td class="style4">
</td>
<td class="style8">
</td>
<td class="style5">
</td>
<td class="style4">
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style9">
</td>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style6">
</td>
<td class="style10">
</td>
<td class="style7">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services><asp:ServiceReference Path="~/MyWebService.asmx" /></Services>
</asp:ScriptManager>
<asp:TextBox ID="search" runat="server" Height="16px" Width="181px"></asp:TextBox>
<cc1:AutoCompleteExtender ID="search_AutoCompleteExtender" runat="server"
MinimumPrefixLength="1" TargetControlID="search"
ServiceMethod="GetHotSearchKeywords" ServicePath="~/MyWebService.asmx"
>
</cc1:AutoCompleteExtender>
</td>
<td class="style6">
<asp:ImageButton ID="imgbtnSearch" runat="server" ImageUrl="~/Images/Search.jpg"
OnClick="imgbtnSearch_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using MyBookShop.BLL;
/// <summary>
///MyWebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class MyWebService : System.Web.Services.WebService
{
public MyWebService()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string[] GetHotSearchKeywords(string keyword, int displayCount)
{
return SearchKerwrodsManager.GetHotSearchKeywords(keyword, displayCount);
}
}
其中GetHotSearchKeywords方法是没问题的!
[解决办法]
代码不看了
只告诉你调试ajax这类程序的技巧,你需要分开隔离调试
1.先测试后端代码是否,按你的思路给出了你期望的结果
2.然后测试前端js是否正常运行
3.使用httpdebuger一类http封包查看工具,查看中间传输和响应过程是否你期望的结果。(ps:ajax是隐藏提交滴你看不到过程,而把看不到的过程,变成看的见的过程,本来就是调试程序的基本手段)