一//直接在js中写
<script language="javascript">
function EnterTextBox()
{ if(event.keyCode == 13 && document.all["TextBox1"].value != "")
{ event.keyCode = 9;
event.returnValue = false;
document.all["TextBox1"].click();
}
}
</script>
<body onkeypress="return EnterTextBox()">
//此处TextBox1为页面上TextBox的ID
二.
<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')");