[英]RadioButtonList OnSelectedIndexChanged
我正在尋找處理在ASP.net RadioButtonList(后面的C#代碼)上選擇的索引更改的最佳方法。 我有3個列表項。 對於第一個,我希望它在頁面上顯示隱藏的asp:文本框,而另外2個將隱藏文本框。
//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。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.