本文介绍了如何在AutoCompleteExtender列表中显示静态不可单击的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个来自Ajax Control Toolkit的AutoCompleteExtender。我需要在下拉列表中有一个标题,但它不应该作为项目选择。



我用jQuery尝试过这个,但即使我只是添加作为div,当我点击它时它仍然被选为文本框中的项目:



我的java脚本代码是:

I have an AutoCompleteExtender from the Ajax Control Toolkit. I need to have a heading in the dropdown list, but it should not be selectable as an item.

I have tried this using jQuery, but even when I just add as a div, it is still selected as an item into the text box when I click on it:

My java script Code is:

<script type="text/javascript">
    // Find the autocompleteextender and set the text as value selected
    function OnItemSelected(event) {
        var selInd = $find("AutoCompleteEx")._selectIndex;
        if (selInd != -1)
            $find("AutoCompleteEx").get_element().value = $find("AutoCompleteEx").get_completionList().childNodes[selInd]._value;

    }

    function OnClientPopulated(sender, eventArgs) {
        //Find the autocompleteextender list
        var autoList = $find("AutoCompleteEx").get_completionList();
        for (i = 0; i < autoList.childNodes.length; i++) {

            // Consider value as image path

            var imgeUrl = autoList.childNodes[i]._value;





            var text = autoList.childNodes[i].firstChild.nodeValue;



            if (text == "header") {

                var newimgeUrl = imgeUrl.split("!");



                autoList.childNodes[i].innerHTML = "<div  style=width:380px;height:30px;background-color:#80BA27;padding:5px;color:black;font-size:16px;text-align:center>Static Heading</div>";



            }

          }

    }

</script>







我在这篇文章中也看到同样的问题:

[]



但是无法解决我的问题所以plz帮助我




I also see the same problem at this post:
Show static non-clickable heading in AutoCompleteExtender list[^]

But Unable to solve my problem so plz help me

推荐答案




这篇关于如何在AutoCompleteExtender列表中显示静态不可单击的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 21:04