gpt4 book ai didi

c# - RadioButtonList OnSelectedIndexChanged

转载 作者:太空狗 更新时间:2023-10-29 17:29:48 26 4
gpt4 key购买 nike

我正在寻找处理在 ASP.net RadioButtonList(后面的 C# 代码)上选择的索引更改的最佳方法。我有 3 个列表项。对于第一个,我希望它在页面上显示一个隐藏的 asp:textbox,而另外两个将隐藏文本框。

//asp.net side
<asp:RadioButtonList ID="_indicatorAckType" runat="server" RepeatDirection="Horizontal"
enabled="true" OnSelectedIndexChanged="onAckTypeChanged">
<asp:ListItem Text="None" />
<asp:ListItem Text="SHOW" />
<asp:ListItem Text="HIDE" />
</asp:RadioButtonList>

//code behind
protected void onAckTypeChanged(object sender, EventArgs e)
{
if (_indicatorAckType.SelectedItem.Text == "SHOW")
_myTextboxID.Visible = true;
else
_myTextboxID.Visible = false;
}

我最初尝试使用 onclick 事件处理程序,但我被告知 ListItem 不能对单选按钮项使用 onclick 事件。我在这里做错了什么?这不会引发任何错误或有任何明显的问题。我试过让 onSelectedIndexChanged 除了显示文本框之外什么都不做,但这也不起作用。

感谢任何帮助!谢谢大家。

最佳答案

在 RadioButtonList 上,将 AutoPostBack 属性设置为 true。

关于c# - RadioButtonList OnSelectedIndexChanged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6983821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com