< script language = " javascript " > function EnterTextBox(button) { if(event.keyCode == 13 && document.all["TextBox1"].value != "") { event.keyCode = 9; event.returnValue = false; document.all[button].click(); } } </ script > 在PageLoad事件里TextBox1.Attribute.add( " onkeypress " , " EnterTextBox('Button1') " ); <form runat="server" defaultbutton="linLogin"> 转载于:https://www.cnblogs.com/freexiaoyu/archive/2008/05/23/1205951.html