日期:2014-05-18  浏览次数:20726 次

asp.net登陆页面里面的DropDownList1_SelectedIndexChanged没有触发,不知道为什么
不知道是不是我逻辑的问题,我这是一个登录界面,可以再DropDownList里面选择身份是学生和管理员,我想实现当DropDownList选项是学生时,页面能够多两个label和新的DropDownList。但是页面运行时这两个label并没有出现。是把这两个label的初始Visible设为false。在 DropDownList1_SelectedIndexChanged里面写:
 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
  if (DropDownList1.SelectedValue == "学生")
  {
  this.Label5.Visible = true;
  this.Label6.Visible = true;
  this.DropDownList2.Visible = true;
  this.DropDownList3.Visible = true;

  }
  }
可是改变选项时,并没有出现应有的结果,是不是应该让页面刷新一下?重新刷新页面的代码是啥啊?

------解决方案--------------------
我搜了下说要设置 DropDownList 属性 AutoPostBack 为 true 才会触发
<asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True"></asp:DropDownList>
这个设置了吗?