The purpose is probably the same as the previous articleArticle
Block the response of the button to the enter return key and implement the "Enter-> tab" Effect
Similar
To prevent
Button-to-Car return key and other non-click actions
Unnecessary misoperation caused by Response
=========== Front-end page ================
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default3.aspx. cs" inherits = "default3" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
<Script language = "JavaScript" type = "text/JavaScript">
VaR nowmouseclick = "";
Function fn_onmousedown ()
{
Nowmouseclick = event. srcelement. ID;
}
Function fn_onclick ()
{
If (nowmouseclick = event. srcelement. ID)
{
Nowmouseclick = "";
Return true;
}
Else
{
If (event. srcelement. ID = "imagebutton1 ")
{
Document. All. button1.focus ();
}
Else if (event. srcelement. ID = "button1 ")
{
Document. All. text1.focus ();
}
Return false;
}
}
Function fn_text1_onkeydown ()
{
If (event. keycode = 13)
{
Document. All. text2.focus ();
Event. keycode = 0;
Event. returnvalue = false;
}
}
Function fn_text2_onkeydown ()
{
If (event. keycode = 13)
{
Document. All. imagebutton1.focus ();
Event. keycode = 0;
Event. returnvalue = false;
}
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Input id = "text1" type = "text" onkeydown = "fn_text1_onkeydown ();"/>
<Input id = "text2" type = "text" onkeydown = "fn_text2_onkeydown ();"/>
<Br/>
<Asp: imagebutton id = "imagebutton1" runat = "server" onclick = "imagebutton1_click"/>
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"/>
</Form>
</Body>
</Html>
========= BackgroundCode==================
Public partial class default3: system. web. UI. page
{< br> protected void page_load (Object sender, eventargs e)
{< br> This. imagebutton1.attributes. add ("onmousedown", "fn_onmousedown ();");
This. imagebutton1.attributes. add ("onclick", "Return fn_onclick ();");
This. button1.attributes. add ("onmousedown", "fn_onmousedown ();");
This. button1.attributes. add ("onclick", "Return fn_onclick ();");
}
protected void imagebutton1_click (Object sender, imageclickeventargs e)
{< br> response. write ("imagebutton1 serve event");
}< br> protected void button#click (Object sender, eventargs e)
{< br> response. write ("button1 serve event");
}< BR >}