【问题标题】:ASP.NET ListItem Text stylingASP.NET ListItem 文本样式
【发布时间】:2013-04-15 14:34:46
【问题描述】:

我有以下 -

    <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>

我喜欢在IndividualEnterprise下划线。

我尝试了类似以下的方法,但没有成功:

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

据我所知:

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

【问题讨论】:

  • 检查这个问题:stackoverflow.com/questions/8123757/… 您可以使用相同的方法根据值将类属性添加到 ListItems
  • 如果文本与传统超链接(也有下划线)冲突,请考虑使用粗体或斜体样式作为替代。

标签: asp.net


【解决方案1】:

你想要单引号 - '。

<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>

【讨论】:

    【解决方案2】:

    您可以在 Text 属性之外添加文本:

    <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>
    

    【讨论】:

      【解决方案3】:

      您可以在 ListItems 的 Text 值中使用 HTML:

      <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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-04
        相关资源
        最近更新 更多