Use the Javascript button control

Source: Internet
Author: User

<% @ 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.