本文介绍了可以同时单击RadioButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RadioButton 吧?我怎么能同时点击它们呢?

RadioButton supposed to be clicked one at a time right?how come I could click it both?

这是我的标记:

<fieldset style="width: 158px; margin-top: 5%;float:left;margin-left:3%;">
    <legend>Add/Update Products</legend>
    <label>
        Add
       <asp:RadioButton ID="RadioButton2" runat="server" />&nbsp;Update<asp:RadioButton ID="RadioButton1" runat="server" />
    </label>
     <br />
    <label>
        Category:
        <br />
        <asp:TextBox align="middle" ID="txtCategory" runat="server" CssClass="textbox1"></asp:TextBox></label>
    <br />
    <label>
        Type:
        <br />
        <asp:TextBox align="middle" ID="txtType" runat="server" CssClass="textbox1"></asp:TextBox></label>
    <br />
    <label>
        Image:
        <br />
        <asp:FileUpload ID="FileUpload1" runat="server" /></label>
    <br />
    <label>
        <asp:Label ID="lblFileStatus" runat="server" Text=""></asp:Label>
        <asp:Label ID="lblFile" runat="server" Text=""></asp:Label>
    </label>
    <label>
        <asp:Button ID="btnAdd" runat="server" Text="Submit" CssClass="btnAdd" Height="36px" Width="84px" OnClick="btnAdd_Click" />
        &nbsp;
   <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="btnCancel" Height="36px" Width="84px" />
    </label>
</fieldset>

我只需要选择一个即可.但是当我尝试再次单击同一按钮两次时标记不会消失.

I need to only choose one. But when I tried to click again the same button twicethe mark won't disappear.

推荐答案

从可用选项列表中仅一个选择是可能的,您需要设置 GroupName 这两个 RadioButtons .设置此属性后,一次只能选择指定组中的一个 RadioButton :

When only one selection is possible from a list of available options you need to set the GroupName for both RadioButtons. When this property is set, only one RadioButton in the specified group can be selected at a time:

<asp:RadioButton ID="RadioButton2" runat="server" GroupName="gr1"/>
&nbsp;Update
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="gr1"/>

这篇关于可以同时单击RadioButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 21:34