文本框将不会显示通过代码进行的.text更改. [英] textbox will not show the .text changes made through code.
本文介绍了文本框将不会显示通过代码进行的.text更改.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Web项目,如果用户在下拉列表或组合框中选择某个值,则文本将添加到文本框中.文本已分配(通过查看调试器),但未显示在网页上.
I have a web project where if the user selects a certain value in a dropdown or combo box, text will be added into a textbox. The text is assigned (by looking the debugger) but is not showing on the webpage.
txtMyTextBox.text = ddMydropdown.text
txtMyOtherTextBox = cboMyCombo.text
我需要添加刷新以显示更改吗?所有控件的autopostback设置为true.
Is there a refresh that I need to add for the changes to show? All control have the autopostback set to true.
推荐答案
将控件放入更新面板和
在加载事件
使用
if(IsPostback)
{
返回;
}
put your controls inside update panel and
at the load event
use
if(IsPostback)
{
return;
}
在您提供的代码中,您正在将组合框的文本分配给文本框控件.
In the code you have provided you are assigning the text of combobox to textbox control.
txtMyOtherTextBox = cboMyCombo.text
在这里您需要使用文本属性
here you need to use text property
txtMyOtherTextBox.Text = cboMyCombo.text
希望对您有所帮助.
Hope this will help you.
您可以像这样使用
you can use like this
txtMyOtherTextBox .Text=ddMydropdown.SelectedItem.Text;
这篇关于文本框将不会显示通过代码进行的.text更改.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文