显示数据转换成文本框的标签OnTextChanged事件 [英] Showing data into Label OnTextChanged event of TextBox
本文介绍了显示数据转换成文本框的标签OnTextChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我说一个输入code到文本框100但进入标签比萨应被标签发短信
保护无效的Page_Load(对象发件人,EventArgs的发送)
{}保护无效txtMain_TextChanged(对象发件人,EventArgs的发送)
{
lblmain.text = txtcat.text;
}
解决方案
的 OnTextChanged
是一个服务器端的事件。这将是更好地使用JavaScript用于此目的是这样的:
<脚本类型=文/ JavaScript的>
功能改变(){
的document.getElementById('<%= lblmain.ClientID%GT;')。innerHTML的=的document.getElementById('<%= txtMain.ClientID%GT;')。值;
}
< / SCRIPT>
然后在你的文本框
来电更改
这样的功能:
< ASP:文本框ID =txtMain=服务器的onkeydown =更改();>< / ASP:文本框>
< ASP:标签ID =lblmain=服务器文本=标签>< / ASP:标签>
let say I enter a code into textbox 100 but into label Pizza should be texted in label
protected void Page_Load(object sender, EventArgs e)
{
}
protected void txtMain_TextChanged(object sender, EventArgs e)
{
lblmain.text = txtcat.text;
}
解决方案
The OnTextChanged
is a server side event . It would be better to use JavaScript for this purpose like this:
<script type="text/javascript">
function change() {
document.getElementById('<%= lblmain.ClientID %>').innerHTML = document.getElementById('<%= txtMain.ClientID %>').value;
}
</script>
And then in your TextBox
call to change
function like this:
<asp:TextBox ID="txtMain" runat="server" onkeydown="change();"></asp:TextBox>
<asp:Label ID="lblmain" runat="server" Text="Label"></asp:Label>
这篇关于显示数据转换成文本框的标签OnTextChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文