[英]ajaxToolkit:ToolkitScriptManager not found
我正在嘗試使AjaxControlToolkit(ACT)自動完成擴展程序正常工作。 它曾經短暫地工作過,但是現在停止工作了,我不知道為什么。 我沒有改變我的項目中可以看到的任何影響到此的東西。
我什至創建了一個全新的VS2013項目,並試圖實現這一目標,但仍然很不愉快。
我看到一些對“ ajaxToolkit:ToolkitScriptManager”的引用,但在任何地方都找不到此引用。 我已經嘗試通過下載以及通過NUGET安裝該工具包,但是它根本無法使用。
我已經在這里嘗試了每個示例,至少有20個或更多,但仍然不是很開心。 如果您有它的工作,請發布您的代碼,因為我的行不通,它毫無意義的發布它是因為我已經嘗試了絕對建議的一切
任何幫助將不勝感激,因為我真的不想設計一些無關緊要的東西來解決這個問題。
謝謝負載
[更新] ToolkitScriptManager已從ACT 15.1中刪除,請參見此處 ,以便回答此問題,但自動完成功能仍無法正常工作
[更新]
這是我放在一起的示例,無論是否帶有[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
指令,該示例仍然不起作用
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestWebSite.WebForm1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="100"
ID="AutoCompleteExtender1"
runat="server"
TargetControlID="TextBox1"></cc1:AutoCompleteExtender>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace TestWebSite
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
string[] s = {"a","b","c","d"};
return s;
}
}
}
您需要通過在@PageDirective的正下方放置以下行來注冊AJAX控制工具包庫
這是ajaxtoolkit
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
那么這就是調用ajaxtoolkit的例子
<cc1:toolkitYouWantToUse/>
大吃一驚
好吧,我有它的工作。 我在VS2013中創建了一個全新的測試項目。 我使用Google Chrome的開發人員功能進行調試,發現我經常遇到500錯誤。 根據我的經驗,這通常是由於我的網址錯誤而導致的,從而導致我檢查了Web服務是否正常運行。 (查看下一節)
解決該問題並知道Web服務可以正常運行后,我進行了一些試驗和錯誤,下面的步驟解決了該問題。 現在,我使用相同的方法在所有項目中使用了AutoCompleteExtender。
(這可能不是這樣做的方法,但我知道它對我有用)
使用如下定義的WebMethod將.asmx文件添加到您的項目中。 實際上,您可以使用任何喜歡配置文件的名稱(例如,參數和返回類型)將其保持不變。 可能還有其他變化,但我不知道它們是什么。 我只知道此配置對我有用。
重新添加AutoCompleteControl。 VS IDE將為您添加@Register指令
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="GetCompletionList"
ServicePath="WebService1.asmx"
MinimumPrefixLength="0"
CompletionInterval="100"
ID="AutoCompleteExtender1"
runat="server"
TargetControlID="TextBox1"></cc1:AutoCompleteExtender>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace TestWebSite
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string[] GetCompletionList(string prefixText, int count)//, string contextKey)
{
string[] s = { "a", "b", "c", "d" };
return s;
}
}
}
//List<string> works just as well as string[]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.