How to correctly understand sender in ASP. NET?

Source: Internet
Author: User

How to correctly understand sender in ASP. NET?

For example:

<Input type = "Submit" id = "A1" value = "Flash" onserverclick = "submit_click" runat = "server">

<Input type = "Submit" id = "A2" value = "bright" onserverclick = "submit_click" runat = "server">

<Input type = "Submit" id = "A3" value = "" onserverclick = "submit_click" runat = "server">

<Input type = "Submit" id = "A4" value = "sub" onserverclick =" submit_click "runat =" server ">

These are the four submit buttons. We know that the events triggered by this button are the same, but how can we differentiate them? Let's take a look at the following:

Public void submit_click (Object sender, eventargs E)

{

Switch (Control) sender). Id)

{

Case "A1": showmsg. Text = "" song yanhao; break;

Case "A2": showmsg. Text = "" Li yingbing; break;

Case "A3": showmsg. Text = "" Fei Wenhua; break;

Case "A4": showmsg. Text = "" Wu Xiaotao; break;

}

}

</SCRIPT>

<Asp: Label id = showmsg runat = server/>

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.