现在的位置: 首页 > 综合 > 正文

指定键让指定的按钮提交

2012年07月22日 ⁄ 综合 ⁄ 共 380字 ⁄ 字号 评论关闭

以回车键为例:

<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);
}

抱歉!评论已关闭.