Javascript – ASP.NET TextBox OnTextChanged Event not fired

asp.netc++javascriptsearchtextbox

I'm trying to add a search functionality where the website sends a request to the server to gather information each time the user enters text (letter by letter). For this I'm in need of OnTextChanged event I assume? I tried using it but the event won't fire.

<asp:TextBox ID="futu_search" type="text" spellcheck="false" placeholder="Search" OnTextChanged="futu_search_TextChanged"  runat="server"></asp:TextBox>

And my code behind:

protected void futu_search_TextChanged(object sender, EventArgs e)
{
       //I kept a break point here to see if it's fired
       //Send requests
}

What do you think is wrong? Do yall have a better solution than the 'OnTextChanged event' to get each key press and for a search box?

Best Solution

Enable autopostback true ..

<asp:TextBox AutoPostback="true" ID="futu_search" type="text" spellcheck="false" placeholder="Search" OnTextChanged="futu_search_TextChanged"  runat="server"></asp:TextBox>

If you want to fire the event when user press key than you have to use java script **onkeyup ** event

<asp:TextBox onkeyup ="return abc(event)" AutoPostback="true" ID="futu_search" type="text" spellcheck="false" placeholder="Search" OnTextChanged="futu_search_TextChanged"  runat="server"></asp:TextBox>


<script>
function abc(evt) {

         ..put here your logic
        }
</script>