下拉列表中选择的索引已更改 [英] selected index changed in dropdownlist
本文介绍了下拉列表中选择的索引已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了这段代码,但是在运行时它无法正常工作,任何人都可以帮助我
I have written this code but during runtime its not working can anyone help me
protected void ddldocumenttype_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddldocumenttype.SelectedItem.Text == "pdf" | ddldocumenttype.SelectedItem.Text == "word")
{
txturl.Visible = false;
fudocs.Visible = true;
}
else
{
txturl.Visible = true;
fudocs.Visible = false;
}
}
推荐答案
您只需为DropDownList添加AutoPostBack="true"
,如下所示:
You just need to add theAutoPostBack="true"
for the DropDownList as follows:
<asp:DropDownList AutoPostBack="true" ID="ddldocumenttype" runat="server"
onselectedindexchanged="ddldocumenttype_SelectedIndexChanged">
<asp:ListItem Text="pdf" Value="pdf" Selected="True"></asp:ListItem>
<asp:ListItem Text="text"></asp:ListItem>
<asp:ListItem Text="word"></asp:ListItem>
</asp:DropDownList>
当下拉列表中的选择更改时,这将导致调用OnSelectedIndexChanged
事件处理程序方法.默认情况下,AutoPostBack
设置为"false"
.
This will cause the OnSelectedIndexChanged
event handler method to be invoked, when the selection is changed in the drop down list. By default, the AutoPostBack
is set to "false"
.
这篇关于下拉列表中选择的索引已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文