Change Color of Specific a Part in Label

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • firebirds98
    New Member
    • Feb 2008
    • 15

    #1

    Change Color of Specific a Part in Label

    I am using .Net and I want to make a specific part of a label a different text color then the label it self.

    Ex.
    Code:
    lblresults.Text = "We found " + objquote.Count.ToString + " results."
    The labels forecolor is Blue but I want the part "objquote.Count .Tostring" part to be red.

    I dont want to use multiple labels.
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    I think what you are describing is not possible without creating your own custom Label control.

    The default provided Label control does not have the ability you are describing. You would have to get creative (like using 2 labels, OR you can use the <asp: Literal> control for something like that and just print out HTML formatting.

    Code:
    'on aspx page
    <asp:Literal id="MyLabel" runat="server" />
    
    'Then in code behind or in page process:
    MyLabel.Text="We found <font color=blue>" & objquote.Count.ToString & " </font>results."

    Comment

    Working...