我在我的学校项目网站上创建注册表单。我给出了安全问题的下拉菜单,如果用户想输入他自己的问题,他/她可以选择其他问题,然后文本框会显示默认情况下我已经设置了visible=false
。如何显示隐藏的文本框下拉selectedindex chnged事件?
我试着用这段代码,但它不工作,有什么我失踪。
protected void selectques_SelectedIndexChanged(object sender, EventArgs e)
{
if (selectques.Text == "Other")
{
alterquestion.Visible = true;
}
}
DROPDOWNLIST:
<asp:DropDownList ID="selectques" runat="server" Height="25px" Width="254px" OnSelectedIndexChanged="selectques_SelectedIndexChanged">
<asp:ListItem>Select a question?</asp:ListItem>
<asp:ListItem> What is your pet name?</asp:ListItem>
<asp:ListItem>Who is your first teacher?</asp:ListItem>
<asp:ListItem>Which is your favourite movie?</asp:ListItem>
<asp:ListItem>Whom you like most in your life?</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
隐藏的文本框:
<asp:TextBox ID="alterquestion" runat="server" Height="20px" Width="250px" Visible="false"></asp:TextBox>
我试着用这两种方法,但仍是同样的结果。 – avirk
有哟设置AutoPostBack =“真”? – Damith
不,我没有。其实我不知道如何处理这个事件。 – avirk