Apr 10, 2010

Search name in listbox on type in textbox in asp.net(complete word)

<script type ="text/javascript">
   function onCheck(sender,args) {
            lst = document.getElementById('<%= lstfreesms.ClientID %>');
            lst.selectedIndex = -1;
            var search_value = sender.value.toUpperCase();
            for (var i = 0; i < lst.options.length; i++) {
                if (lst.options[i].text.toUpperCase() == search_value) {
                    lst.options[i].selected = true;
                    break;
                }
            }
        }
    </script>

<td>
                            <asp:TextBox ID="txtsearch" runat="server" onkeyup="onCheck(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                         
                            <asp:ListBox ID="lstfreesms" runat="server" Width="200px"></asp:ListBox>
                        </td>
 if (!IsPostBack)
            {
               

               

                DataSet ds1 = new DataSet();
                ds1 = cu.getUsers();
                lstfreesms.DataSource = ds1;
                lstfreesms.DataTextField = "username";
                lstfreesms.DataValueField = "id";
                lstfreesms.DataBind();

            }


No comments:

Post a Comment