Use C # (JavaScript) to operate the Asp.net 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"> // attaches a value to the commandargument attribute of the button protected void button#click (Object sender, eventargs e) {This. button. commandargument = "button";} protected void button_click (Object sender, eventargs e) {// print the commandargument attribute response of the button. write (button) sender ). com Mandargument);} protected void button2_click (Object sender, eventargs e) {response. write ("Wang AI Hui client conform");} protected void button3_click (Object sender, eventargs e) {response. write ("Wang AI Hui arrisponconform");} // You can pass the attributes attribute of the button to add a confirmation dialog box to the button. Protected void page_load (Object sender, eventargs e) {This. button3.attributes. add ("onclick", "Return confirm ('arrisponconfrim Are you true ') "); // button7.attributes. add ("onmouseover", "currentcolor = This. style. backgroundcolor; this. style. backgroundcolor = 'blue' "); // button7.attributes. add ("onmouseout", "this. style. backgroundcolor = currentcolor ");} protected void buttons_command (Object sender, commandeventargs e) {If (E. commandname = "B4") {response. write ("select top 10 * From mytable order by ID" + E. commandargument );} If (E. commandname = "B5") {response. write ("select top 10 * From mytable2 order by name" + E. commandargument);} If (E. commandname = "B6") {response. write ("select top 10 * from" + E. commandargument + "order by id desc ");}} </SCRIPT> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 

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.