JS代码
<script type= "text/javascript " language= "javascript ">
function SubmitKeyClick(button)
{
if (event.keyCode == 13)
{
event.keyCode=9;
event.returnValue = false;
document.all[button].click();
}
}
// -->
</script>
要触发事件的 服务控件 代码
<asp:ImageButton id= "ImageButton1 " runat= "server " ImageUrl= "~/Img/login2_button.gif " OnClick= "ImageButton1_Click "> </asp:ImageButton>
<asp:ImageButton id= "ImageButton2 " runat= "server " ImageUrl= "~/Img/register.gif " PostBackUrl= "~/Reg.aspx " CausesValidation= "False "> </asp:ImageButton>
CS代码
if (!this.IsPostBack)
{
txtPwd.Attributes.Add( "onkeydown ", "SubmitKeyClick( 'ImageButton1 '); ");
}
提示这个 错误 请问高手那个地方出错了啊
提示: "Microsoft JScript 运行时错误: 'document.all[...] ' 为空或不是对象 "
------解决方案--------------------------------------------------------
<script type= "text/javascript " language= "javascript ">
function SubmitKeyClick(button)
{
if (event.keyCode == 13)
{
event.keyCode=9;
event.returnValue = false;
document.all[ImageButton1].click();
}
}
// -->
</script>
------解决方案--------------------------------------------------------
txtPwd.Attributes.Add( "onkeydown ", "SubmitKeyClick( 'ImageButton1 '); ");
“txtPwd”是什么东西?这能运行么?
------解决方案--------------------------------------------------------
应该是他的page里面的一个TextBox控件的ID。
------解决方案--------------------------------------------------------
关注一下
------解决方案--------------------------------------------------------