简体   繁体   English

在Uframe中使用C#将文本框值绑定到标签框中

[英]Bind a textbox value in a label box using c# inside a uframe

I have entered a value in text box and click the button the value should bind in a label. 我在文本框中输入了一个值,然后单击该值应绑定在标签中的按钮。 The code must be in c# not in query. 该代码必须在c#中而不在查询中。 There is no database also.how please say the code behind in c#. 也没有数据库。如何在c#中说后面的代码。 It is button click event. 是按钮点击事件。 while click the button the page should post back and bind the data how to bind a textbox value in a label box using c#. 在单击按钮时,页面应回发并绑定数据,以及如何使用c#绑定标签框中的文本框值。 The value must bind in postback method. 该值必须以回发方法绑定。

It as easy as the following: 就像下面这样简单:

LabelID.Text = TextBoxID.Text;

Where LabelID is the ID of your Label control and TextBoxID is the ID of your TextBox control. 其中LabelID是Label控件的ID,而TextBoxID是TextBox控件的ID。

You should place this code inside the button click's event. 您应该将此代码放置在按钮单击事件中。

Update 更新资料

Please use for your purpose ASP.NET Web Server Controls . 请出于您的目的使用ASP.NET Web服务器控件

<asp:TextBox ID="textBoxId" runat="server"/>

<asp:Label ID="labelId" runat="server"/>

Then you can access the values of Text property of both the above controls, like above: 然后,您可以访问上述两个控件的Text属性的值,如上所示:

labelId.Text = textBoxId.Text;

easy , take a look at the below code: 容易,请看下面的代码:

<asp:TextBox Id="txt1" runat="server" />

<asp:button Id="btn1" runat="server" onClick="Button1_Click"/>
<asp:Label Id="lbl1" runat="server"/>

//in the code behind implement the Button1_Click //在实现Button1_Click的代码后面

protected void Button1_Click (object sender, EventArgs e)
{

lbl1.Text= txt1.Text;

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM