Add Icon to Text Box in Label Control

I want to know if there is a way to add an icon to asp.net label text.

So, something like

<asp:Label run="server"
Text= "Please see the "icon" below />

Thank.

+3
source share
3 answers

You cannot use a property textthis way - the line textends with "before the word icon.

However, any HTML markup will not be escaped, so you can use the tag <img>.

<asp:Label run="server"
   Text="Please see the <img src='icon.gif' /> below" />

From MSDN (Label.Text):

The Text property may contain HTML. If so, the HTML will be passed unchanged to the browser, where it can be interpreted as markup, not as text.

asp:image Label.

+5

. asp- , . , asp.net

<asp:Label
    AccessKey="string"
    AssociatedControlID="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
        Inset|Outset"
    BorderWidth="size"
    CssClass="string"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
        Large|X-Large|XX-Large"
    Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    ID="string"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    Text="string"
    ToolTip="string"
    Visible="True|False"
    Width="size"
/>
0

There is no direct way.

However, you can use a simple HTML tag <label>with an attribute for="id"attached to ImageButton, for example

<asp:ImageButton ID="ToggleButton" runat="server" ImageUrl="~/images/expand.gif" onclick="ToggleButton_Click" />
<label ID="ToggleButtonLabel" for="ToggleButton" runat="server">Range Summary</label>
0
source

Source: https://habr.com/ru/post/1779062/


All Articles