Posted By

weldonr30 on 06/23/12


Tagged

jquery aspnet linkbutton


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrockSamsom


jQuery and Clicking an ASP.NET Linkbutton


 / Published in: jQuery
 

URL: http://www.mitchelsellers.com/blogs/2012/06/21/jquery-and-clicking-an-aspnet-linkbutton.aspx

This is a pretty standard jQuery method to listen for the enter key and simply "click" the button. However, if you are using a LinkButton this code will not work. The reason for this is that a LinkButton is rendered to the browser as an Anchor tag with a href property that contains a javascript action to trigger the postback. Click does nothing on the button as there is nothing for it to complete.

  1. $("#<%=txtPassword.ClientID %>").keydown(function(event) {
  2.  
  3. if (event.keyCode == 13) {
  4.  
  5. eval($("#<%=btnLogin.ClientID %>").attr('href'));
  6.  
  7. }
  8.  
  9. });

Report this snippet  

You need to login to post a comment.