troubleshooting Question

Insert / Add a Carriage Return or Line Feed into a Label

Avatar of RAMCIT
RAMCIT asked on
ASP.NET
2 Comments1 Solution2622 ViewsLast Modified:
Hi,

I am trying to insert a carriage return or line feed into a label.  I have a web app in ASP.NET with VB.NET in code behind.

I have the following text:

John Smith, 123 Main Street, AnyCity, AnyState 12345-6789

I need to display it as follows in a label:

John Smith
123 Main Street
AnyCity, AnyState 12345-6789

I have tried all of the following but none of them work:

lblSampleLabel.Text = lblSampleLabel.Text & vbCrLf
lblSampleLabel.Text = lblSampleLabel.Text & vbCr
lblSampleLabel.Text = lblSampleLabel.Text & vbLf
lblSampleLabel.Text = lblSampleLabel.Text & "<br>"
lblSampleLabel.Text = lblSampleLabel.Text & vbNewLine
lblSampleLabel.Text = lblSampleLabel.Text & Chr(13)
lblSampleLabel.Text = lblSampleLabel.Text & Chr(10)

I also have the CssClass of the label set to the following item in the Style Sheet:

.MultiLineLabels {
    border-style: solid;
    border-color: #000000;
    border-width: 1px;
    background-color: #ffffff;
    font-size: xx-small;      
    font-family: Verdana;
    color:Black;
    vertical-align:middle;
    text-align:left
    }

Any help or guidance would be greatly appreciated.

Thanks!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros