<% @ Page Language = "C #" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<SCRIPT runat = "server">
Protected void button#click (Object sender, eventargs E)
{
This. textbox1.text = "Happy New Year! ";
}
Protected void button2_click (Object sender, eventargs E)
{
This. textbox1.text = "Happy New Year! Happy New Year! ";
}
</SCRIPT>
<HTML xmlns = "http://www.w3.org/1999/xhtml">
Function textbox1_onkeydown ()
{
If (event. keycode = 13)
{
_ Dopostback ("button2 ","");
}
} //]>
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: textbox id = "textbox1" onkeydown = "Return textbox1_onkeydown ()" runat = "server"> </ASP: textbox>
<Br/>
<Asp: button id = "button1" runat = "server" text = "button1" onclientclick = "Return confirm ('Are you true? ') "Onclick =" button#click "/>
<Br/>
<Asp: button id = "button2" runat = "server" text = "button2" onclick = "button2_click"/>
<Asp: dropdownlist id = "dropdownlist1" width = "0px" runat = "server" autopostback = "true"> </ASP: dropdownlist>
</Div>
</Form>
</Body>
</Html>
Certificate -----------------------------------------------------------------------------------------------------------------------------------------------
This page has a text box and two buttons,
The confirmation box is displayed after the first button is clicked,
If you click OK and then send it back to the server,
If you click Cancel, it will not be returned to the server,
The second button is directly submitted to the server,
When you press the Enter key in the text box,
Trigger the click event of button2 and submit it back to the server for execution,
To change the value of the text box, add a dropdownlist control to this page,
Set the autopostback attribute to true,
This is because the _ dopostback () function is automatically generated on the page,
So that we can call it in JavaScript.