问题描述
希望有人能够帮助这一点。我一直在向上和向下的网站,并通过该网站寻找答案,但还是不能让自动完成AJAX控制工作。我已经从试图将其纳入现有的网站,以剥离其右后卫一个非常基本的形式消失,它仍然无法正常工作。我在使用页面方法而不是本地Web服务多一点运气,所以这里是我的code
Hope someone can help with this. I've been up and down the web and through this site looking for an answer, but still can't get the Autocomplete AJAX control to work. I've gone from trying to include it in an existing site to stripping it right back to a very basic form and it's still not functioning. I'm having a little more luck using Page Methods rather than a local webservice, so here is my code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="droptest.aspx.cs" Inherits="droptest" %>
<%@ 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>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
</asp:ScriptManager>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
MinimumPrefixLength="1" ServiceMethod="getResults"
TargetControlID="TextBox1">
</cc1:AutoCompleteExtender>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Services;
using System.Web.Services;
public partial class droptest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public string[] getResults(string prefixText, int count)
{
string[] test = new string[5] { "One", "Two", "Three", "Four", "Five" };
return test;
}
}
试图让事情尽可能的简单,但我得到的要么是自动完成的下拉与页面(首先是&LT;!DOCTYPE ...
)逐个字母,或在IE7它只是说未定义一路下跌的列表中。
Tried to keep things as simple as possible, but all I get is either the autocomplete dropdown with the source of the page (starting with the <! doctype...
) letter by letter, or in IE7 it just says "UNDEFINED" all the way down the list.
我使用的Visual Web Developer 2008的时刻,这是在本地主机上运行。我想我已用尽了所有从加在[ScriptMethod]在Web.Config中改变事物试试这个...选项可以找我,应有尽有。
I'm using Visual Web Developer 2008 at the moment, this is running on Localhost. I think I've exhausted all the "Try this..." options I can find, everything from adding in [ScriptMethod] to changing things in Web.Config.
这有什么明显错误与此code?
Is there anything obviously wrong with this code?
这是唯一的其他东西可能的是具有效果是在Global.asax中我做了Context.RewritePath重写URL - 这确实对AJAX任何影响
Only other thing that may be having an effect is in Global.asax I do a Context.RewritePath to rewrite URLs - does this have any effect on AJAX?
感谢您的帮助,您可以给。
Thanks for any help you can give.
推荐答案
右键,事情我已经从这些建议中加入了工作!还有一个问题,虽然,它工作在一个独立的项目,但将它放回现有项目,它不工作了。所以,感谢您的帮助,到目前为止,我有一个工作的例子,只是要弄清楚什么现在是杀害它的另一项目中。
Right, something I've added in from these suggestions has worked!!! Still have a problem though, it works in a standalone project but adding it back into the existing project and it's not working again. So thanks for the help so far, I have a working example, just have to figure out what is killing it inside the other project now.
这篇关于撕裂我的头发 - ASP.Net AJAX自动完成不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!