ASP.NET页面本身没有办法自己实现,这里使用客户端的javascript脚本检查用户的每一次按键,如果为回车,那么提交表单,注意程序中两个颜色不同的控件名称必须与你的ASPX页面中的控件的名称完全一致,其中Form1为页面表单的ID,btn_Select是需要回车触发的服务器按钮的名称。
<script language="javascript">
function KeyDownHandler()
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
Form1.btn_Select.click();
}
}
</script>
<script language="javascript">
function KeyDownHandler()
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
Form1.btn_Select.click();
}
}
</script>