我想讓我的Ajax AutoCompleteExtender看起來像這樣 - http://jquery-sew.s3-website-us-east-1.amazonaws.com/。 建議列表將在括號中顯示代碼及其名稱。 例如:C01(瑞典)。當選擇一個項目時,只有代碼將顯示在文本框中。Jquery像C#中的AutoCompleteExtender一樣#
在這裏的幫助下,我能夠用兩個連接名稱獲得建議列表加載。現在卡在最後一部分。
這個想法是在item select上獲得回發,然後在服務器端執行字符串刪除操作。它是否正確。
編輯:
JAVASCRIPT:
function itemSelected(source, eventArgs) {
var hdnID = document.getElementById('<%= hdnValue.ClientID %>');
hdnID.value = eventArgs.get_value();
__doPostBack(hdnId, "");
}
ASPX:
<asp:hiddenfield id="hdnValue" onvaluechanged="hdnValue_ValueChanged" runat="server"/>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="ace" runat="server" TargetControlId="txtSearch"
MinimumPrefixLength="2" EnableCaching="true" CompletionSetCount="10"
CompletionInterval="0" ServiceMethod="GetCodes" UseContextKey="True"
CompletionListCssClass="autoComplete"
CompletionListItemCssClass="autoCompleteItem"
CompletionListHighlightedItemCssClass="autoCompleteHL"
onclientitemselected="itemSelected">
</asp:AutoCompleteExtender>
ASPX.CS:
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static string[] GetCodes(string prefixText)
{
CountryBLL objCountry = new CountryBLL();
return objDAL.GetCodes(prefixText);
}
protected void hdnValue_ValueChanged(object sender, EventArgs e)
{
//perform string remove action.
}
回發爲n不幸的是在這裏發病。
你有jQuery插件或C#代碼的問題? – Patel
它只是我不知道jQuery。 – Ruby