0

嗨,我使用单个文本框来查询不同类型的选择,例如,当我选择第一个 RadioButton(姓氏)时,我按客户姓氏搜索,当我选择第二个 RadioButton(文档代码)时,我按代码搜索,依此类推,请我如何管理或处理异常,例如,如果用户选择“按日期搜索”并发送字符串类型?

我使用 C# 3.5 - Asp.net

我想用正则表达式制作它并将其添加到 RadioButton 事件中,因此当用户更改收音机时,他可以在 optionA 中仅键入一些字符,在 Option B 中键入更多字符,在 OptionC 中键入日期 ...(正则表达式)

提前感谢

4

1 回答 1

1

如果您使用的是 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)"

}
于 2009-01-26T21:30:20.233 回答