C#如何将不同按钮的按钮文本设置为同一文本框

C#如何将不同按钮的按钮文本设置为同一文本框,c#,asp.net,button,textbox,C#,Asp.net,Button,Textbox,我有两个按钮和一个文本框。我想这样,当我按下按钮1时,文本框中的文本进入按钮,当我按下按钮2时,文本进入按钮2,依此类推。我现在有这个: protected void Button1_Click(object sender, EventArgs e) { Button1.Text = TextBox1.Text; } protected void Button2_Click(object sender, EventArgs e) {

我有两个按钮和一个文本框。我想这样,当我按下按钮1时,文本框中的文本进入按钮,当我按下按钮2时,文本进入按钮2,依此类推。我现在有这个:

protected void Button1_Click(object sender, EventArgs e)
    {

        Button1.Text = TextBox1.Text;
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Button2.Text = TextBox1.Text;
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        Button3.Text = TextBox1.Text;
    }

编辑:是否有较短的方法执行此操作?

如果将每个按钮的
单击事件指向相同的方法,则可以在类似的一种方法中执行此操作

protected void Button_Click(object sender, EventArgs e)
{
    ((Button)sender).Text = TextBox1.Text;
}

您可以在设计器中更改按钮事件使用的方法,方法是:单击按钮,转到属性窗口,单击事件的小发光符号,然后为
单击事件选择
按钮\u单击
方法。

((按钮)发送者)。Text=TextBox1.Text您需要按下按钮吗?是的,当我单击按钮时,我希望文本框中的文本进入按钮。然后@EdPlunkett的注释就是您的解决方案