我的自动完成功能在使用旧网站时工作正常,但在移植到 C# 和实体框架时无法正常工作。下面的 HTML 是用户控件的一部分。我已经在 web 服务代码中放置了断点,它甚至看起来都没有被调用。我不知道在哪里可以查看休息时间。任何帮助,将不胜感激。谢谢。
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:TextBox ID="TextBoxDamName" runat="server" Columns="50"></asp:TextBox>
<asp:AutoCompleteExtender ID="TextBoxDamName_AutoCompleteExtender"
runat="server"
DelimiterCharacters=""
Enabled="True"
ServicePath="DamSafetyAutoComplete.asmx"
ServiceMethod="SelectDamNames"
FirstRowSelected="True"
MinimumPrefixLength="1"
CompletionInterval="200"
TargetControlID="TextBoxDamName">
</asp:AutoCompleteExtender></td>
namespace ExternalDamSafetySearch
{
/// <summary>
/// Summary description for DamSafetyAutoComplete
/// </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 DamSafetyAutoComplete : System.Web.Services.WebService
{
[WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] SelectDamNames(string prefixText, Int32 count)
{
try
{
EnterprisePubEntities EE = new EnterprisePubEntities();
return EE.DamSafetyDatas
.Take(count)
.Where(c => c.DamName.StartsWith(prefixText))
.Distinct()
.OrderBy(c => c.DamName)
.Select(c => c.DamName)
.ToArray();
}
catch (Exception) { throw; }
}
}
}