Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
Hi,
I have to display some data on Labels from the database in asp.net. But the newline character and different text styles cannot be displayed. All datas are appearing as same formatting and in a single line. Can you please help me for solving this problem.
I am using c# coding.

Thanking you...
Posted
Updated 13-Jul-11 18:35pm
v5
Comments
Sergey Alexandrovich Kryukov 13-Jul-11 16:34pm    
Tag it! WPF or Forms, or what?!
--SA
Venkatesh Mookkan 13-Jul-11 23:55pm    
I guess he is talk about Web.

Different styles for the same label? The class Label won't help you; you need a different class to do such things.

One of these components can help you:
WPF HTML Supported TextBlock[^],
A Professional HTML Renderer You Will Use[^].

Both works offer components based on HTML rendering, one for WPF, another for Forms. (Always tag UI library you want to use, don't force people in doing double work.)

If you use the above components, new line will be <br/>. If you keep using plain-text labels, new line in general case is not '\n' or '\r' or combination. You need to use portable way. Use System.Environment.NewLine.

—SA
 
Share this answer
 
v2
I don't know what newline character is used. But maybe you can replace it with
BtWhatever.Text = stringFromDB.Replace(dbNewlineChar, "\r\n");
 
Share this answer
 
Comments
Neha Thanka 13-Jul-11 7:37am    
Now i am using this method. Is there any other method? Can we use text toolbox while entering data in textbox and display the data as there in a label?
lukeer 13-Jul-11 8:11am    
Why would someone downvote this solution?

OP even commented that he is using it at the moment (I hope he didn't just mix up the solutions at hand).

If it is indeed that bad, it would be helpful to tell everyone why. So that we all (and by "we all", I mean "I myself") can learn something and stop posting rubbish solution approaches.
If you have problem only with newline character you can use "<br>" in place of "\n" or if you want any other special characters, images etc in your Lebel you can use Literal control in place of Label.
 
Share this answer
 
Comments
Neha Thanka 13-Jul-11 8:02am    
Thanks for your reply...

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