日期:2014-05-20  浏览次数:20400 次

求教关于TextBox控件的显示问题!
我设置了一个DropdowmList控件和一个TextBox控件,TextBox的Visible属性设置为false。问题是当我选中DropdowmList控件中的某个特定的Text值时,要让TextBox控件显示出来,该如何去做,谢谢!

------解决方案--------------------
可以有两种方式,在服务器端,把DropdownList的autopostback属性设为true,在change事件中写
TextBox1.Visible = true;
客户端
<asp:TextBox id= 'c ' />

<asp:DropdownList id= 'd ' onchange= "aa() "/>

<script>
function aa()
{
if(document.getElementById( 'd ').value = '你的值 ')
{
document.getElementById( 'c ').visible = true;
}
}
</script>

大概这样,你改一下
------解决方案--------------------
后台的方法
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
this.DropDownList1.AutoPostBack = true;
}
}
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
TextBox1.Visible = true;
}