我有几个按钮和一个文本框。当我按下button1时,我想让文本框中的文本传输到button1,当我按下button2时,文本将传输到button2,以此类推。我现在有以下代码:
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;
}
编辑:有没有更简单的方法来完成这个任务?
((Button)sender).Text = TextBox1.Text;
- 15ee8f99-57ff-4f92-890c-b56153