代码之家  ›  专栏  ›  技术社区  ›  Jonathan Escobedo

关于单选按钮检查更改事件

  •  0
  • Jonathan Escobedo  · 技术社区  · 16 年前

    您好,我使用一个TextBox来查询不同类型的选择,例如当我选择第一个单选按钮(姓氏)时,我按客户端姓氏搜索,当我选择第二个单选按钮时(Doc.Code),我按代码搜索等等,请问当用户选择“按日期搜索”并发送字符串类型时,我该如何管理或处理异常?

    我使用的是C#3.5-Asp.net

    我想用正则表达式来实现它,并将其添加到RadioButton事件中,这样当用户更改单选按钮时,他可以在选项A中键入一些字符,在选项B中键入更多字符,并在选项C中键入日期。..(正则表达式)

    提前致谢

    1 回复  |  直到 16 年前
        1
  •  1
  •   TStamper    16 年前

    如果你使用的是aspweb控件radiobuttonlist,那么当它们是回发时,你可以进行很多更改。您可以将该属性设置为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)"
    
    }
    
    推荐文章