ASP.NET AJAX postback and jQuery

Posted by Echilon on Stack Overflow See other posts from Stack Overflow or by Echilon
Published on 2010-02-02T17:45:39Z Indexed on 2010/03/23 16:03 UTC
Read the original article Hit count: 401

Filed under:
|
|
|

I have a Textbox, a LinkButton and a RadioButtonList inside an UpdatePanel. When the button is clicked, the UpdatePanel shows matching items in the radiobuttonlist.

This works fine, but I now need to make the same happen OnKeyDown on the TextBox. I'm trying to cancel all AJAX requests in progress but not having much luck. Firstly, on every keypress the UpdatePanel posts back, so only one letter can be changed at a time. Secondly, the textbox loses focus on postback.

I need to show the list as normal, but OnKeyDown as well as when the button is pressed. This is what I have (control IDs shortened)

$('#textBoxId').live('keydown', function(e) { 
  if((e.keyCode >= 47 && e.keyCode <= 90) || e.keyCode == 13) {
    Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
    $('#buttonId').click();
    $('#textBoxId').focus();
  }
});

Thanks for any insight.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery