问题内容:
在asp.net中,如何回车触发指定按钮的事件?
假设:
<asp:TextBox ></asp:TextBox>
<asp:Button ></asp:Button>

解决方法:
在.aspx页面中添加:
<SCRIPT LANGUAGE="javascript">
function SubmitKeyClick(button)
{   
if (event.keyCode == 13)
{       
event.keyCode=9;
event.returnValue = false;
document.all[button].click();
}
}
// -->
</SCRIPT>

在Page_Load事件中添加:
tbInput.Attributes.Add("onkeydown","SubmitKeyClick('btnOK');");

相关文章:

  • 2021-10-25
  • 2021-11-10
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
猜你喜欢
  • 2022-02-12
  • 2021-07-04
  • 2021-07-19
  • 2022-12-23
  • 2021-12-09
  • 2022-01-31
相关资源
相似解决方案