Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi all,


I am having "Name: Raj" in my Label box. I want only "Raj" should be in bold.

Shall we do this in a single label box or have to place two label box.

How to do this?

Regards,
Pal
Posted

You can't do it in a single label - you have to use two.
Labels (and many other controls) do not support any rich text features - any formatting applies to the whole control.
However, you could do it by inheriting from Label and handling paint yourself.
 
Share this answer
 
An HTML Label control is given in this Code Project article.
A Professional HTML Renderer You Will Use[^]
I think it may be helpful to you.
 
Share this answer
 
use this:
C#
this.lblName.Text = "My Name Is < b >Raj< / b >";


Regards,
Akaas Developer
 
Share this answer
 
v4
Comments
[no name] 18-Apr-12 16:15pm    
How does displaying "My Name Is < b >Raj< / b >" in a label control make the text bold?
You can use div control insteadof label control
XML
<div runat="server" id="div">My Name Is <b>Raj</b></div>
 
Share this answer
 
v2
By using split method,you can split and bold the name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900