By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,969 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,969 IT Pros & Developers. It's quick & easy.

Breaks in labels

P: n/a
I am writing some text in a multiline text box to a database . When I
display this in a label all the breaks have disappeared. I will be using
formviews a lot so I need a solution that works with bound data. In ASP I
used to use the replace function to replace chr(13) with "<br>". I am not
sure the how to do this in .net. Is there some simple setting or do I have
create my own version of a label and overide an event. I am a little unsure
of how to do this. Regards, Chris.
Jun 3 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Chris" <no****@nospam.comwrote in message
news:Oo**************@TK2MSFTNGP06.phx.gbl...
>I am writing some text in a multiline text box to a database . When I
display this in a label all the breaks have disappeared. I will be using
formviews a lot so I need a solution that works with bound data. In ASP I
used to use the replace function to replace chr(13) with "<br>". I am not
sure the how to do this in .net. Is there some simple setting or do I have
create my own version of a label and overide an event. I am a little unsure
of how to do this. Regards, Chris.

string strText = "This is a multiline label\\r\\nwith a line break";
MyLabel.Text = strText.Replace(\\r\\n, "<br />");
--
http://www.markrae.net

Jun 3 '07 #2

P: n/a
Is there any way of building a composite control and overiding its databound
(I'm guessing the event name) so I can use the label without do the code all
the time? Bear in mind I am quite new the .net. Regards, Chris.

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OM**************@TK2MSFTNGP02.phx.gbl...
"Chris" <no****@nospam.comwrote in message
news:Oo**************@TK2MSFTNGP06.phx.gbl...
>>I am writing some text in a multiline text box to a database . When I
display this in a label all the breaks have disappeared. I will be using
formviews a lot so I need a solution that works with bound data. In ASP I
used to use the replace function to replace chr(13) with "<br>". I am not
sure the how to do this in .net. Is there some simple setting or do I have
create my own version of a label and overide an event. I am a little
unsure of how to do this. Regards, Chris.


string strText = "This is a multiline label\\r\\nwith a line break";
MyLabel.Text = strText.Replace(\\r\\n, "<br />");
--
http://www.markrae.net

Jun 3 '07 #3

P: n/a
"Chris" <no****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Is there any way of building a composite control and overiding its
databound (I'm guessing the event name) so I can use the label without do
the code all the time? Bear in mind I am quite new the .net.
You could build a control if you wanted to, but I can't really see that it
would save you any time and/or code...

However, it might be worthwhile as a learning exercise:
http://www.google.co.uk/search?sourc...ite+control%22
--
http://www.markrae.net

Jun 3 '07 #4

P: n/a
your own control is a good solution and pretty simple:
public class MultiLineLabel : Label
{
override string Text
{
get {return base.Text;}
set {base.Text = value.Replace("\\r\\n","<br />"); }
}
}
-- bruce (sqlwork.com)

Chris wrote:
Is there any way of building a composite control and overiding its databound
(I'm guessing the event name) so I can use the label without do the code all
the time? Bear in mind I am quite new the .net. Regards, Chris.

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OM**************@TK2MSFTNGP02.phx.gbl...
>"Chris" <no****@nospam.comwrote in message
news:Oo**************@TK2MSFTNGP06.phx.gbl...
>>I am writing some text in a multiline text box to a database . When I
display this in a label all the breaks have disappeared. I will be using
formviews a lot so I need a solution that works with bound data. In ASP I
used to use the replace function to replace chr(13) with "<br>". I am not
sure the how to do this in .net. Is there some simple setting or do I have
create my own version of a label and overide an event. I am a little
unsure of how to do this. Regards, Chris.

string strText = "This is a multiline label\\r\\nwith a line break";
MyLabel.Text = strText.Replace(\\r\\n, "<br />");
--
http://www.markrae.net

Jun 4 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.