Last post Feb 23, 2010 08:10 AM by prashant11
Feb 17, 2010 02:38 AM|prashant11|LINK
I have facing problem of giving color to string format in label control.
I have one lable and label of text is "I m .Net developer" so i want display only string "developer" as Red color.
Plz somebody help me.
Feb 21, 2010 08:57 AM|adeelehsan|LINK
One workaround can be setting the text of the label at runtime using embedded html tags. You need to find out at runtime, which part of the string you want to give red color. Then you can embed <font> tag to the give the color. Following is an example:
Me.Label1.Text = "Hello There Too"
' To change the color
Me.Label1.Text = "Hello <font color='red'>There</font> Too"
Now as I said, you need to know the specific part to which you want to give red color, dynamically.
Feb 22, 2010 02:39 AM|prashant11|LINK
I tried but it will display as it string on page.
Feb 22, 2010 03:05 AM|adeelehsan|LINK
Are you applying any css on this label. That might be the reason of this. You can use try the following:
Me.Label1.Text = Server.HtmlDecode("Hello <font color='red'>There</font> Too")
Server.HtmlDecode will cause any embedded html to render correctly.
Feb 22, 2010 04:33 AM|prashant11|LINK
not working same problem is coming it again show string on form.
Feb 22, 2010 04:42 AM|vijjendra|LINK
You can use as follows:
Your ASPX page like:
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server"></asp:Label>
protected void Page_Load(object sender, EventArgs e)
Label1.Text = "I m .Net <font color='red'>developer.</font>";
Feb 23, 2010 08:10 AM|prashant11|LINK
I m using mobile Label control in my application will it is use?