我想實現自動提示文本box.I已經檢查了其他職位似乎沒有任何要工作我,我無論是在Web應用程序試圖與website.Please在我的代碼計算outthe錯誤英寸當我在文本框中鍵入字母時,什麼都不會發生。我可以在瀏覽器中看到webservice結果。自動提示使用AJAX
delete.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Delete.aspx.cs"
Inherits="WebApplication2.Delete" %>
<%@ Register TagPrefix="ajaxToolkit" Namespace="AjaxControlToolkit"
Assembly="AjaxControlToolkit"%>
<!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 id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true"
EnablePartialRendering="true"
runat="server">
</asp:ScriptManager>
<asp:TextBox ID="myTextBox" runat="server" Width="400px" ></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender runat="server" ID="autoComplete1"
TargetControlID="myTextBox"
ServiceMethod="Information"
ServicePath="~/WebService1.asmx"
OnClientItemOut="Information"
MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="5"
ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
</div>
</form>
</body>
webservice1.asmx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace WebApplication2
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[System.Web.Services.WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[]Information(string prefixText)
{
RDFEntities db = new RDFEntities();
var allrows = from s1 in db.RDFMatch_v where s1.RIC.StartsWith(prefixText) select s1.RIC;
return allrows.ToArray();
}
}
}
我很想知道爲什麼你沒有考慮jQuery自動完成。 – Shyju
你能否給我提供鏈接,我會試試。 – Radha
http://jqueryui.com/autocomplete/ – Shyju