I have never experienced such behavior personally. The DefaultButton property has always worked for me in Chrome, but there is a way around it if you cannot smooth it. You can enter short JavaScript in the controls for which you want to launch buttons. The following is a non-jQuery method:
StringBuilder script = New StringBuilder(""); script.Append("if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {"); script.Append("document.getElementById('" + Me.btnToFire.ClientID); script.Append("').click();return false;}} else {return true};"); this.txtControlToAttach.Attributes.Add("onkeydown", script.ToString());
Here is a jQuery solution that can be used to assign multiples in one block (unverified, so configuration may need to be done).
function fireButtonClick(ctrl, event) { if(event.which || event.keyCode){ if ((event.which == 13) || (event.keyCode == 13)) { ctrl.click(); return false; } } else { return true; } } $(document).ready(function() { $("#<%=this.ControlToAttach.ClientID%>").keypress(function(event) { fireButtonClick($("#<%=this.btnToFire.ClientID%>"), event); }); $("#<%=this.ControlToAttach2.ClientID%>").keypress(function(event) { fireButtonClick($("#<%=this.btnToFire2.ClientID%>"), event); });
source share