我在我的學校項目網站上創建註冊表單。我給出了安全問題的下拉菜單,如果用戶想輸入他自己的問題,他/她可以選擇其他問題,然後文本框會顯示默認情況下我已經設置了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