views:

1714

answers:

2

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

+1  A: 

You'll want to look into server controls. (You can provide client-side validation in addition, though it is mainly for user convenience.) These two links should get you started:

Noldorin
I was thinking in use RegularExpression for format the unique TextBox, is that possible?
Angel Escobedo
Yep, there's a RegularExpressionValidator control for precisely that. See the MSDN page in my post.
Noldorin
+1  A: 

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

}
TStamper