PC Review


Reply
Thread Tools Rate Thread

Breaks in labels

 
 
Chris
Guest
Posts: n/a
 
      3rd Jun 2007
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.


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      3rd Jun 2007
"Chris" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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

 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      3rd Jun 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Chris" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      3rd Jun 2007
"Chris" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> 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

 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      4th Jun 2007
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "Chris" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word has decided to convert my Next page section breaks to Continuoussection breaks Mi Tasol Microsoft Word Document Management 2 28th Jun 2010 05:42 AM
Labels Report and Page Breaks adnan.rangwala@gmail.com Microsoft Access Reports 0 18th Jan 2007 09:30 PM
Hard breaks in text to soft breaks in Excel tbailey Microsoft Excel Misc 6 28th Jul 2005 02:35 AM
Hard breaks in text to soft breaks in Excel tbailey Microsoft Excel Programming 2 26th Jul 2005 04:06 AM
Find & Replace Line Breaks with Paragraph Breaks Jeremy Microsoft Frontpage 9 18th May 2004 09:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:12 PM.