开发者

asp.net autocomplete combobox functions in javascript

开发者 https://www.devze.com 2023-03-08 23:41 出处:网络
Does asp ajaxtoolkit autocomplete combobox have some javascript functions available, s开发者_StackOverflow社区o we could select selecteditem text or selected item value in client side.

Does asp ajaxtoolkit autocomplete combobox have some javascript functions available, s开发者_StackOverflow社区o we could select selecteditem text or selected item value in client side.

Thanks Atif


If you mean this, here you can download the complete source code with all js files:

http://ajaxcontroltoolkit.codeplex.com/

Otherwise, here is a short documentation:

http://www.asp.net/ajax/ajaxcontroltoolkit/samples/autocomplete/autocomplete.aspx

I think, you can control this behaviour through the completion service method, where is up to you, how you implement it.


<script type="text/javascript">
    function autoComplete1_OnClientShown(sender, eventArgs) {
        var valueToSelect = $("#<%= TextBox1.ClientID  %>").val();

        if (valueToSelect.length > 0) {
            var itemToSelect = $("li[_value^='" + valueToSelect + "']", ".CompletionList").get(0);
            Sys.Debug.traceDump(itemToSelect);
            if (itemToSelect)
                $find("AutoCompleteEx")._setText(itemToSelect);
        }
    }
</script>

<asp:Label runat="server" AssociatedControlID="TextBox1" Text="Select the first value that starts with: " />
    <asp:TextBox runat="server" ID="TextBox1" />&nbsp;
    <br />
    <asp:Label ID="Label1" runat="server" AssociatedControlID="TextBox2" Text="Choose value: " />
    <asp:TextBox runat="server" ID="TextBox2" />
    <ajax:AutoCompleteExtender runat="server"
            BehaviorID="AutoCompleteEx"
            ID="autoComplete1" 
            TargetControlID="TextBox2"
            ServicePath="Default.aspx" 
            ServiceMethod="GetCompletionList"
            MinimumPrefixLength="2" 
            DelimiterCharacters=";, :"
            CompletionListCssClass="CompletionList"
            OnClientShown="autoComplete1_OnClientShown"
            ShowOnlyCurrentWordInCompletionListItem="false" >
     </ajax:AutoCompleteExtender>
0

精彩评论

暂无评论...
验证码 换一张
取 消