【发布时间】:2014-05-09 19:59:25
【问题描述】:
但是不行,我在web服务中放了一个断点,但是没有进入web服务!!
<asp:TextBox ID="txt_empName" runat="server" Width="300px" ></asp:TextBox>
<cc1:AutoCompleteExtender ID="txt_empName_AutoCompleteExtender" runat="server"
CompletionListCssClass="autocomplete_completionListElement" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
CompletionListItemCssClass="autocomplete_listItem" Enabled="True" MinimumPrefixLength="4"
OnClientItemSelected="get_emp_num" UseContextKey="True" ServiceMethod="Get_Emp_AutoComplete"
ServicePath="~/EmpAutoComplete.asmx" TargetControlID="txt_empName" BehaviorID="ACE_empName"
EnableCaching="False">
</cc1:AutoCompleteExtender>
我的网络服务:
[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 AutoComplete : System.Web.Services.WebService
{
[WebMethod]
public List<string> Get_Emp_AutoComplete(string prefixText, int count, string contextKey)
{
//split the string in the text box to get the department equivalent to the last prefix text entered in the textbox after ',' or ';'
string[] s = prefixText.Split(new string[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries);
if (s.Length > 0)
{
prefixText = s[s.Length - 1].Trim();//Last item in the array
}
List<string> Emp_List = Get_RequestEmp(prefixText, contextKey);
return Emp_List;
}
public static List<string> Get_RequestEmp(string prefixText, string contextKey)
{
prefixText = prefixText.Trim().Replace(' ', '%');
DBConnection ConnectionObj = new DBConnection(CMSession.GetSession("code", HttpContext.Current), false);
string cmdText = "SELECT emp_num , trim(name) FROM grrt5emp WHERE name LIKE '%" + prefixText + "%' ORDER BY name";
DataTable dt = ConnectionObj.Return_DataTable(cmdText);
List<string> Emp_List = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
//Returning key-value pair
Emp_List.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dt.Rows[i][1].ToString(), dt.Rows[i][0].ToString()));
}
return Emp_List;
}
}
我的 AjaxToolkit 版本是:
3.0.30930.28736
【问题讨论】:
-
可能.Net版本不匹配?
-
@huseyintugrulbuyukisik:那你能给我正确的版本吗
标签: asp.net ajax web-services autocomplete ajaxcontroltoolkit