Nate Pet
Nate Pet

Reputation: 46282

ASP.NET ListItem Text styling

I have the following -

    <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Vertical" RepeatLayout="Table" CssClass="RBL" TextAlign="Right">

      <asp:ListItem Text= "Individual - This is for user" />

      <asp:ListItem Text="Enterprise - This is for enterprises" />

    </asp:RadioButtonList>

What I like to do is to underline just Individual and Enterprise.

I tried something like the following but did not work:

    <asp:ListItem Text= <span class="underline"> Individual </span>-....

as I got:

    Error   71  The 'Text' property of 'asp:ListItem' does not allow child objects.

Upvotes: 0

Views: 5975

Answers (3)

nmat
nmat

Reputation: 7591

You can add your text outside of the Text attribute:

<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Vertical" RepeatLayout="Table" CssClass="RBL" TextAlign="Right">
  <asp:ListItem> <span class="underline">Individual</span> - This is for user </asp:ListItem>
  <asp:ListItem> <span class="underline">Enterprise</span> - This is for enterprises </asp:ListItem>    
</asp:RadioButtonList>

Upvotes: 1

Win
Win

Reputation: 62290

You want single quote - '.

enter image description here

<style type="text/css">
    .underline { text-decoration: underline; }
</style>

<asp:RadioButtonList ID="RadioButtonList1" runat="server" 
   RepeatDirection="Vertical" RepeatLayout="Table" CssClass="RBL" TextAlign="Right">
    <asp:ListItem Text="<span class='underline'>Individual</span> - This is for user" />
    <asp:ListItem Text="<span class='underline'>Enterprise</span> - This is for enterprises" />
</asp:RadioButtonList>

Upvotes: 3

MikeTWebb
MikeTWebb

Reputation: 9279

You can use HTML in the Text value for the ListItems:

<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Vertical" RepeatLayout="Table" CssClass="RBL" TextAlign="Right">

  <asp:ListItem Text= "<u>Individual</u> - This is for user" />

  <asp:ListItem Text= "<u>Enterprise</u> - This is for enterprises" />

</asp:RadioButtonList>

Upvotes: 0

Related Questions