【问题标题】:TextBox filtering according to RadioButton selection根据 RadioButton 选择的 TextBox 过滤
【发布时间】:2012-11-07 17:08:14
【问题描述】:

我有一个RadioButtonList 和一个TextBox。根据 RadioButtonList 选择,我想过滤文本框。

 <asp:RadioButtonList ID="RadioButtonList1"  runat="server"  AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
      <asp:ListItem Text="NUMBER" Value="1" Selected="True"></asp:ListItem>
      <asp:ListItem Text="TEXT" Value="2"></asp:ListItem>
</asp:RadioButtonList>

 <asp:TextBox ID="txtID" runat="server">

当我单击值为1 的列表项时,用户可以在文本框中输入数字。值2,数字+文本。 我也想设置长度。有人可以告诉我怎么做吗?

【问题讨论】:

  • 我不想使用 Ajax 控件工具包
  • 不清楚您想要什么或尝试过什么。是否要根据RadioButtonList 中的选择在 javascript 中过滤该 TextBox?
  • 是的,我想在 javascript 中更改文本框的过滤器类型。一个选项,它将是数字文本框。

标签: c# javascript asp.net


【解决方案1】:

编写一个 Javascript 函数,该函数将从 RadioButtonList1 控件中获取选定的值,并与值 12 进行比较。如果是1,应该只允许用户输入数字。这可以从文本框的客户端按键事件中强制执行,该事件将检查比较结果,以允许按下的键实际呈现在文本框中。

参考this 了解如何使用JavascriptRadioButtonList 控件中获取选定值

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-24
    • 2013-07-10
    相关资源
    最近更新 更多