C# .NET - onkeypress event in the C# - Asked By muthuraman alexander on 02-Dec-11 04:29 AM

hi all,

i have a asp:textbox and a asp:dropdownlist
i need to populate the drop down when the text is entered in the text box............
for example when i enter a postal code in the text box, city names for that postal code in the database should populated in the drop down

i have done this is in OnTextChanged  event of the text box..but this havent meet the expectation...
while trying the on key press ,.it was a client side event
one way for this is we can use ajax to call the server side method from the jquery...

but i dnt know how to implement this   or  any other way for this solution............?

i need to populate the drop down when the text is entered in the text box............

please any body advice me

thanks in advance
muthu




Reena Jain replied to muthuraman alexander on 02-Dec-11 05:00 AM
Hi,

For Jquery you must change the event name from "change" to "onchange":
$(document).ready(function(){
    $("input#tags").bind("onchange", autoFill);
      });
 
or use the shortcut binder method change:
 
$(document).ready(function(){
    $("input#tags").change(autoFill);
      });

Note that the onchange event usually fires when the user leave the input, so for auto-complete you better use the keydown event.