简体   繁体   中英

About RadioButton CheckedChanged event

Hi there im using a single TextBox for querying differents types of chossings, for example when i select the first RadioButton (Last Name) I search by Client last name, when i choose second RadioButton (Doc. Code) I search by code and so on, please how can i manage or handle exceptions when for example if user choose "Search by Date" and send a string type?

Im using C# 3.5 - Asp.net

I would like to make it with regular expressions and add that in the RadioButton event, so when users changes radio, he could type just some characters in optionA, other more in Option B, and just dates in OptionC ... (regular expression)

Thanks in advances

if you are using the asp web control radiobuttonlist then you can make lots of changes when their is a postback. you can set the attribute to SelectIndexChanged,so whenever their is a change it cause a postback and then you can do whatever from their(verifications). ex:

   <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>

on the server you should have

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)"

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM