0

我在一个文本框上使用 ajax 自动完成扩展器,我还在其他两个文本框和一个 jquery Image 滑块上使用日历扩展器。但是我的自动完成扩展器不起作用。但是当我在新项目中使用相同的代码时,它运行良好。我的搜索控制代码是:

<asp:Label ID="Label1" runat="server" Text="Desired Location you want to Search?&nbsp;"></asp:Label></label>
        <asp:TextBox ID="txtSearch" runat="server" onfocus="if(this.value=='Type Location Here !') this.value='';"
            onblur="if(this.value=='') this.value='Type Location Here !';" CssClass="txtbox"
            Width="520px">Type Location Here !</asp:TextBox>
              <asp:AutoCompleteExtender  ID="autosearch" runat="server" TargetControlID="txtSearch"
            ServiceMethod="GetCompletionList" CompletionSetCount="10" UseContextKey="true" ContextKey="SearchKey"
            Enabled="true" EnableCaching="true" MinimumPrefixLength="1" CompletionInterval="100"
            CompletionListCssClass="autocomplete_list" ScriptPath="SearchInputControl.ascx.cs" 
            CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlighted_listitem" >
        </asp:AutoCompleteExtender>

Javascript 错误:

Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; AskTbTRL2/5.15.4.23821) Timestamp: Thu, 1 Nov 2012 06:59:14 UTC     
Message: Sys.ArgumentUndefinedException: Value cannot be undefined. 
Parameter name: type Line: 4620 Char: 12 Code: 0 
4

1 回答 1

0

looks like onfocus and onblur are your show stoppers. remove them and retry.

Basically, you can not directly add these events to asp.net textbox like this. use txtSearch.Attributes.Add('onfocus','jscode') way to add these events.

于 2012-11-01T07:08:45.987 回答