为什么列表框选中的索引发生了变化? [英] why listbox selected index changed is not firing?

查看:83
本文介绍了为什么列表框选中的索引发生了变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为sortlistbox项目编写了一个javascript方法,它很好地工作,我在文本框中输入的项目变得很高,但是当我点击突出显示的项目时,它会被选中为什么?选定的indexchanged无效。这是我的javascript代码:



i have written a javascript method to sortlistbox items it works well in a sence that the item that i type in text box gets highlited but when i click on the highlighted item it dosent gets selected why? the selected indexchanged is not working. here is my javascript code:

function SearchList() {
         var l = document.getElementById("<%= LBox.ClientID %>");
         var tb = document.getElementById("<%= txtDepartments.ClientID %>");
         if (tb.value == "") {
             ClearSelection(l);
         }
         else {
             for (var i = 0; i < l.options.length; i++) {
                 if (l.options[i].value.toLowerCase().match(tb.value.toLowerCase())) {
                     l.options[i].selected = true;

                     return false;
                 }
                 else {
                     ClearSelection(l);
                 }
             }
         }
     }

     function ClearSelection(l) {
         l.selectedIndex = -1;
     }

推荐答案

自动回发改为真........ ..........
Make auto post back to True..................


一旦突出显示,就会被选中。单击所选项目不会更改索引,因此不会触发selectedIndexChanged事件。
Once it's highlighted, it is selected. clicking on a selected item does not change the index, so does not fire the selectedIndexChanged event.


这篇关于为什么列表框选中的索引发生了变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆