簡體   English   中英

關於RadioButton CheckedChanged事件

[英]About RadioButton CheckedChanged event

嗨,我使用一個TextBox查詢不同類型的選擇,例如,當我選擇第一個RadioButton(姓氏)時,我按客戶端姓氏搜索;當我選擇第二個RadioButton(文檔名)時,我按代碼搜索,依此類推,例如,如果用戶選擇“按日期搜索”並發送字符串類型,請問如何管理或處理異常?

我正在使用C#3.5-Asp.net

我想使用正則表達式添加它,並將其添加到RadioButton事件中,因此,當用戶更改單選按鈕時,他可以在optionA中僅鍵入一些字符,在Option B中鍵入其他字符,並在OptionC中鍵入日期...(正則表達式)

預先感謝

如果您使用的是ASP Web控件單選按鈕列表,那么當它們是回發時,您可以進行很多更改。 您可以將屬性設置為SelectIndexChanged,因此只要它們的更改會導致回發,然后您就可以從其驗證中進行任何操作。 例如:

   <asp:radioButtonList
     id="radio1" runat="server" 
     autoPostBack="true"
     cellSpacing="20"
     repeatColumns="3"
     repeatDirection="horizontal"
     RepeatLayout="table"
     textAlign="right"
     OnSelectedIndexChanged="radio_SelectedIndexChanged">
     <asp:ListItem text="10pt" value="itsMe"/>  
     <asp:ListItem text="14pt" value="itsYou"/>  
     <asp:ListItem text="16pt" value="Neither"/>  
  </asp:radioButtonList>

在您應該擁有的服務器上

protected void radio_SelectedIndexChanged(object sender, EventArgs e)
{
 //do whatever you want by calling the name of the radio id
 //example

  if(radio1.SelectedItem.Value=="(whatever you want to test)"

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM