用我的应用程序我添加了ajax auto complete extender在那个扩展器中我使用了“OnClientPopulated”事件,对于那个事件我在javascript写一个函数,它工作IE,Chrome,Safari但不用firefox因为这个事件无法在firefox中触发, 我在那里写了以下代码:
<ajax:AutoCompleteExtender OnClientPopulated="getSearch_Populated" ID="AutoCompleteExtenderSearch"
runat="server" TargetControlID="txtSearchbox" MinimumPrefixLength="1" Enabled="true"
EnableCaching="true" CompletionSetCount="12" CompletionInterval="1000" ServiceMethod="GetAppNames"
ServicePath="~/AutoComplete.asmx" DelimiterCharacters="" UseContextKey="true"
CompletionListCssClass="AutoExtender" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
CompletionListItemCssClass=".AutoExtenderList" OnClientItemSelected="selected_Search">
</ajax:AutoCompleteExtender>
JavaScript的:
function getSearch_Populated(sender, e) {
var searchList = sender.get_completionList().childNodes;
var searchText = sender.get_element().value;
for (var i = 0; i < searchList.length; i++) {
var search = searchList[i];
var searchValueArray = (search._value).split("|");
var searchId = searchValueArray[0];
var searchUrl = searchValueArray[1];
var link = document.createElement('a');
var href = document.createAttribute('href');
link.setAttribute('href', searchUrl);
link.innerText = searchId;
search.appendChild(link);
}
}
答案 0 :(得分:0)
它在firefox中完美适用于我。我是这样做的:
<asp:TextBox ID="TBAjaxSzallitasiCim" runat="server" Text="<%$Resources:WLO_Web,lbl_kereso %>"
Style="font-style: italic" Width="250"></asp:TextBox><cc1:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender"
runat="server" ServicePath="AutoCompleteFeeder.asmx" ServiceMethod="Cimvalaszto"
TargetControlID="TBAjaxSzallitasiCim" CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
CompletionInterval="1000" DelimiterCharacters=";" CompletionSetCount="10" FirstRowSelected="true"
EnableCaching="true" Enabled="true" OnClientPopulating="ShowImage" OnClientPopulated="HideImage"
OnClientItemSelected="ace0_itemSelected">
</cc1:AutoCompleteExtender>
<asp:HiddenField ID="ace0Value" runat="server" />
使用Javascript:
function ShowImage() {
document.getElementById('ctl00_ContentPlaceHolder1_TBAjaxSzallitasiCim')
.style.backgroundImage = 'url(Images/circle-ball-dark-antialiased.gif)';
document.getElementById('ctl00_ContentPlaceHolder1_TBAjaxSzallitasiCim')
.style.backgroundRepeat = 'no-repeat';
document.getElementById('ctl00_ContentPlaceHolder1_TBAjaxSzallitasiCim')
.style.backgroundPosition = 'right';
}
function HideImage() {
document.getElementById('ctl00_ContentPlaceHolder1_TBAjaxSzallitasiCim')
.style.backgroundImage = 'none';
}
我正在使用这个库:
<%@ Register TagPrefix="cc1" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit, Version=3.5.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" %>
这位剧本管理员:
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" CombineScripts="false"
AsyncPostBackTimeout="300" EnableHistory="true" EnablePageMethods="true">
</cc1:ToolkitScriptManager>