2012-08-25 50 views
0

我有一个标签和textbox1textbox2和一个按钮。我输入文字textbox1如何检索文本框的值

然后点击该按钮,如何显示textbox1textbox2

+0

你应该把名字,显示那些是什么文本框的 - 即txtName的,txtAge,等等 –

回答

0
this.textbox2.Text = this.textbox1.Text; 
5

添加点击事件处理你的按钮,并设置TextBox2中

<form id="form1" runat="server"> 
    <div> 
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> 
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> 
    </div> 
</form> 

在你的代码文件的文本属性 ...

protected void Button1_Click(object sender, EventArgs e) 
{ 
    TextBox2.Text = TextBox1.Text; 
} 
0

在您按一下按钮加入此代码

textbox2.Text = textbox1.Text; 
0

双击该按钮。这会让你进入代码隐藏文本。在此之后写

textBox1.Text = textBox2.Text; 
0
void Button1_Click(object sender, eventargs e) 
{ 
    TextBox1.Text = TextBox2.Text; 
}