Click here to Skip to main content
15,749,288 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating an user control with asp textbox .To add the KeyDown And KeyUp Event I am using the below code.When User typing some text in the text box the listbox is filtered and show the list. Its working Perfect .But if I am using more than user controls in my page,when i type in one control all controls list boxes are showing. How can i prevent this?
<asp:TextBox ID="txtBox" runat="server" onkeydown="onTxtKeyDown();"  onkeyup="onTxtKeyUp();"  >

 <asp:Button runat="server" ID="btnSearch" Style="display: none" OnClick="HandleAjaxCall"/>
      <asp:Label runat="server" ID="lblStatus" />

 protected void HandleAjaxCall(object sender, EventArgs e)

 <script type="text/javascript">
     var to; // variable to which we assign setTimeout function
     var prm = Sys.WebForms.PageRequestManager.getInstance(); // Page Request Manager object
     function onTxtKeyUp() {
         to = setTimeout('performSearch();', 300);
     function onTxtKeyDown() {
         if (to) clearTimeout(to);
     function performSearch() {
         if (prm.get_isInAsyncPostBack) {
         $get("<%=lblStatus.ClientID %>").innerHTML = "Loading...";
         __doPostBack("<%=btnSearch.UniqueID %>", "");
Updated 5-Aug-13 21:38pm
Joezer BH 6-Aug-13 3:35am    
"when i type in one control all controls list boxes are showing"
What list boxes are showing?
I didn't understand your problem, please explain some more

ALSO - what is the "protected void HandleAjaxCall" function doing outside the Script tag?
Member 8390746 6-Aug-13 5:09am    
protected void HandleAjaxCall() is btnSearch.Click Event . It is a code behind method

Iam created a user control called txtLOV
My control contains a textbox and listbox .When I typing some text in the textbox the listbox is filtered and visible property is set to true and user can selct one of the item from listbox. Its working properly. Now I am using this txtLOV in pages.I am adding many txtLOVs in my page. when I am typing a text in txtLOV1s textbox I want to show the listbox of txtLOV1, but now all txtLOVs listbox visible properties are set to true.
wladimirbm 6-Aug-13 3:46am    
write BindDataToListView here
wladimirbm 8-Aug-13 5:21am    
may be you have same names?

1 solution

What is wrong with the onKeyUp javascript event?
<html xmlns="">
<head  runat="server">
    <script type="text/javascript">
        function KeyReleased() {
            // Do what you want
            // Example:
            var a = document.getElementById("TextBox1").value;
            document.getElementById("divResult").innerHTML = a;
            return true;
    <form id="form1"  runat="server">
        <asp:TextBox ID="TextBox1" onKeyUp="KeyReleased()" runat="server"></asp:TextBox>
        <div id="divResult"></div>
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900