将文本从文本框移至标签 [英] Move text from textbox to label

查看:103
本文介绍了将文本从文本框移至标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi iam sriram iam更新鲜
我的任务:我现在在ASP Web应用程序中使用了1labelcontrol,1textbox,1button,我的问题是我想要的代码,以便如果我在文本框中输入我的名字,该名字在执行后应该显示在标签中,请您帮助我.
[edit]主题:始终使用反映问题的主题,而不是您的经验水平,它可以帮助我们知道我们是否可以在该主题上提供帮助-OriginalGriff [/edit]

hi iam sriram iam a fresher
my task:i have taken 1labelcontrol,1textbox,1button in asp webapplication now my problem i want code such that if i enter my name in textbox the name should display in label after execution please help me kindly

[edit]Subject: always use a subject that reflects the problem, not your experience level, it helps us to know if we can assist on that subject - OriginalGriff[/edit]

推荐答案

这听起来像是您的作业,所以没有代码!

处理按钮单击事件:双击设计器中的按钮,它将带您进入处理程序的代码.
然后,您需要将Text属性从TextBox(我怀疑会假想地称为"textBox1")复制到Label的Text属性(我想会称为"label1").

属性访问:controlname.propertyname
分配:destination = source
This sounds like your homework, so no code!

Handle the button click event: double click on the button in the designer and it will take you to the code fro the handler.
Then you need to copy the Text Property from the TextBox (which will imaginatively be called "textBox1" I suspect) into the Text Property of the Label (which I imagine will be called "label1").

Property access: controlname.propertyname
Assignment: destination = source


只需尝试在文本框的TextChanged事件中编写代码

Just try to write the code in TextChanged event of textbox

Label1.Text=TextBox1.Text;


设置TextBox属性:


set TextBox property :

Autopostback=TRUE;



这里TextBox1,Label1是控件的ID.



here TextBox1,Label1 are ids of controls.


请尝试以下操作:

try this:

private void button1_Click(object sender, EventArgs e)
{
  string name=textbox1.Text;
  label1.text=name;
}



希望这会有所帮助:)



hope this helps :)


这篇关于将文本从文本框移至标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆