指定键让指定的按钮提交

以回车键为例:

<script language="javascript" event="onkeydown" for="document">

if(event.keyCode==13)
{
if (document.activeElement.id=='指定ID')
{
document.all('按钮ID').focus();
document.all('按钮ID').click();
}
}
</script>



c#

private void Page_PreRender(object sender, EventArgs e)
{
this.TextBox1.Attributes["onkeydown"] =
"if(event.keyCode==13)" + this.Page.ClientScript.GetPostBackEventReference(this.Button1, null);
}
原文地址:https://www.cnblogs.com/lovewife/p/1437560.html