0

I'm confused with the alignment setting of the radio button list in asp.net, it shows in visual basic like this.

But if i compile it, it shows in my browser like this.

My code for this radio button list.

<td align="right" colspan="2">
                        <asp:RadioButtonList TextAlign="left" ID="RadioButtonList1" runat="server">
                            <asp:ListItem Text="Fixed Cost" Selected="true" Value="1"></asp:ListItem>
                            <asp:ListItem Text="Per Guest Charge" Value="2"></asp:ListItem>
                            <asp:ListItem Text="Percentage" Value="3"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>

How come this happened? I want to get the view like in visual basic, please help.

--- Update ---

This is the result if i change the alignment into "right".

Here's the HTML.

<tr>
                    <td align="right" colspan="2">
                        <table id="ctl00_MainContent_RadioButtonList1" border="0">
        <tr>
            <td><input id="ctl00_MainContent_RadioButtonList1_0" type="radio" name="ctl00$MainContent$RadioButtonList1" value="1" checked="checked" /><label for="ctl00_MainContent_RadioButtonList1_0">Fixed Cost</label></td>
        </tr><tr>
            <td><input id="ctl00_MainContent_RadioButtonList1_1" type="radio" name="ctl00$MainContent$RadioButtonList1" value="2" /><label for="ctl00_MainContent_RadioButtonList1_1">Per Guest Charge</label></td>
        </tr><tr>
            <td><input id="ctl00_MainContent_RadioButtonList1_2" type="radio" name="ctl00$MainContent$RadioButtonList1" value="3" /><label for="ctl00_MainContent_RadioButtonList1_2">Percentage</label></td>
        </tr>
Sam
  • 7,252
  • 16
  • 46
  • 65
sephtian
  • 445
  • 2
  • 11
  • 23

1 Answers1

0

Have you tried setting <asp:RadioButtonList TextAlign="right" - you have TextAlign="left"?

I think your result HTML (being <table> in your addition above) is not guaranteed - ASP.NET may emit <span> in other cases/browsers.

Your best option seems to be assigning a CssClass <asp:RadioButtonList ... CssClass="yourClass"> in combination with some jQuery or direct styling of the possible elements.

See this broader discussion and also the accepted answer in this thread.

Community
  • 1
  • 1
G. Stoynev
  • 7,389
  • 6
  • 38
  • 49