Search code examples
asp.netradiobuttonlist

Align text in asp:Radiobuttonlist


The image below is the current situation of my problem.

enter image description here

How to make the text to stay right after the radiobutton? Below is my code:

<div class="form-group">
<div class="col-sm-2">
    <asp:Label ID="AutoContra" CssClass="control-label" runat="server" Font-Bold="true">Auto Contra</asp:Label>
</div>
<div class="col-sm-1">:</div>
<div class="col-sm-2">
    <asp:RadioButtonList ID="autcon" runat="server" CssClass="radio" RepeatLayout="Flow" RepeatDirection="Horizontal">
        <asp:ListItem Text="Yes" Value="1" Selected="True"></asp:ListItem>
        <asp:ListItem Text="No" Value="0"></asp:ListItem>
    </asp:RadioButtonList>
</div>
<div class="col-sm-1"><span style="color:red;">*</span></div>
</div>

Any helps? Thanks!


Solution

  • use radio button css style cssclass="rbl"

    <style type="text/css">
       .rbl input[type="radio"]
       {
            margin-left: 20px;
            margin-right: 5px;
       }
    </style>
    <asp:RadioButtonList   ID="autcon" runat="server" CssClass="rbl" RepeatLayout="Flow" RepeatDirection="Horizontal">
       <asp:ListItem Text="Yes" Value="1" Selected="True"></asp:ListItem>
       <asp:ListItem Text="No" Value="0"></asp:ListItem>
    </asp:RadioButtonList>