日期:2014-05-20  浏览次数:20344 次

如何让button响应回车
我的aspx上有多个 <asp:Button> ,.net默认第一个响应回车,如何设置,可以使第二个默认响应啊?

------解决方案--------------------
<form id= "form1 " defaultbutton= "button1 " runat= "server ">
button1为你要设置button的ID
------解决方案--------------------
JS:
function GetFocus()
{
if(window.event.keyCode==13)
{
document.all.btnGo.focus();
}
}
使页面响应onKeyDown事件
------解决方案--------------------
JS:
function GetFocus()
{
if(window.event.keyCode==13)
{
document.all.btnGo.click();
}
}

------解决方案--------------------
http://community.csdn.net/Expert/topic/5241/5241129.xml?temp=.4040338
------解决方案--------------------
不好意思还以为是winform中呢,web上面设置默认焦点即可(.net1.X通过脚本)

<body onload= "document.forms[0][ 'button1 '].focus(); ">

.net2就在代码中直接设置就可以了