前端js代码,放到<head>标签下
<script type="text/javascript">
function EnterTextBox(button) {
if (event.keyCode == 13 && document.all["TextBox1"].value != "") {
event.keyCode = 9;
event.returnValue = false;
document.all[button].click();
}
}
</script>
后台代码
页面加载时的代码
PRotected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("onkeypress", "EnterTextBox('Button1')");
}