在ASP.Net2.0中多个通过回车键提交表单时执行特定的button按钮事件
<asp:Panel id=Panel1 runat=server DefaultButton="Button1">
<asp:TextBox id=TextBox1 runat=server/>
<asp:Button id=Button1 runat=server Text="Button1"/>
</asp:Panel>
============================附:另外一种作为的解决方法===================================
写一个脚本,在文本框中加一个OnKeyDown的事件
<form id="Form1" method="post" runat="server">
<asp:TextBox id=TextBox1 runat="server" OnKeyDown="SetFocus2()"></asp:TextBox>
<asp:TextBox id=TextBox2 runat="server" OnKeyDown="SetFocus2()"></asp:TextBox>
<asp:Button id=Button1 runat="server" Text="Button"></asp:Button>
<asp:ImageButton id=ImageButton1 runat="server" ImageUrl="idx_46_x.gif"></asp:ImageButton>
<asp:Label id=Label1 runat="server">Label</asp:Label>
</form>
<script language="javascript">
function SetFocus2()
{
switch(window.event.keyCode)
{
case 13:
document.all.ImageButton1.focus();
}
}
</script>
判断是按Enten键(window.event.keyCode 为13)时执行
<asp:TextBox id=TextBox1 runat=server/>
<asp:Button id=Button1 runat=server Text="Button1"/>
</asp:Panel>
============================附:另外一种作为的解决方法===================================
写一个脚本,在文本框中加一个OnKeyDown的事件
<form id="Form1" method="post" runat="server">
<asp:TextBox id=TextBox1 runat="server" OnKeyDown="SetFocus2()"></asp:TextBox>
<asp:TextBox id=TextBox2 runat="server" OnKeyDown="SetFocus2()"></asp:TextBox>
<asp:Button id=Button1 runat="server" Text="Button"></asp:Button>
<asp:ImageButton id=ImageButton1 runat="server" ImageUrl="idx_46_x.gif"></asp:ImageButton>
<asp:Label id=Label1 runat="server">Label</asp:Label>
</form>
<script language="javascript">
function SetFocus2()
{
switch(window.event.keyCode)
{
case 13:
document.all.ImageButton1.focus();
}
}
</script>
判断是按Enten键(window.event.keyCode 为13)时执行