asp.net的TextBox回车触发事件
<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>
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/None.gif)
在PageLoad事件里
TextBox1.Attribute.add("onkeypress","EnterTextBox('Button1')");
<form runat="server" defaultbutton="linLogin">
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/None.gif)
{
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
{
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://sunsjorlin.cnblogs.com/Images/OutliningIndicators/None.gif)
<form runat="server" defaultbutton="linLogin">