Showing posts with label newlines. Show all posts
Showing posts with label newlines. Show all posts

Thursday, March 22, 2012

Newline Characters

I added a newline to a string using: ControlChars.NewLine

I want to convert all those newlines to "<br>"

i tried:


Replace(myString, cStr(ControlChars.NewLine) , "<br>")

but it had no effect at all. any ideas?I think it is the other way around:


Replace(myString, "<br>", cStr(ControlChars.NewLine))

If you're using VB, don't you have access to the vbCrLf constant? If so you might be able to do

Replace(myString, vbCrLf, "<br>")

or

Replace(myString, Chr(13), "<br>")
Hello,

i always replace my newline with the help ofRegular Expression code like in the following example...

// Remove the newline's and replace them with <br /> tag
Regex inRegex;
inRegex = new Regex("\n", RegexOptions.IgnoreCase);
lblTest.Text = inRegex.Replace(sText, "<br />");
This sample is written in C# but it should be easy to translate to vb.net. If you need further help please post again...

HTH,
thanks guys,

it worked! btw, what does vbcrlf stand for?
vbcrlf --> I believe it is "VisualBasic CarriageReturn and Line Feed"
Or you can use Environment.NewLine no matter what language you are using.

Friday, March 16, 2012

Newlines in Datagrid

I have a very simple Datagrid with one bound field. The field has
Environment.NewLines in it. When the datagrid is rendered, they don't
appear.

I have tried a few of different ways to get them to appear:

1.) Replace Environment.NewLine with <br> before saving to the
database.
2.) Replace Environment.NewLine with </br> before saving to the
database.

Neither of these work because ASP.NET just ends up printing out the
literal <br>, </br>.

Is there a way to replace the Environment.NewLines when the datagrid is
rendered? Alternatively, is there a specific value I should be saving
to get the Datagrid to properly render the <br>?Best solution for me is to create a template column
and then replace the ItemTemplate label with a multiline textbox..

We show addresses like that and it works.

HTH.

Gerhard

<chrismichaelgardner@.hotmail.com> wrote in message
news:1126037176.699190.204720@.z14g2000cwz.googlegr oups.com...
>I have a very simple Datagrid with one bound field. The field has
> Environment.NewLines in it. When the datagrid is rendered, they don't
> appear.
> I have tried a few of different ways to get them to appear:
> 1.) Replace Environment.NewLine with <br> before saving to the
> database.
> 2.) Replace Environment.NewLine with </br> before saving to the
> database.
> Neither of these work because ASP.NET just ends up printing out the
> literal <br>, </br>.
> Is there a way to replace the Environment.NewLines when the datagrid is
> rendered? Alternatively, is there a specific value I should be saving
> to get the Datagrid to properly render the <br>?

newlines in textboxes

I have some multiline textboxes in a page and I'd like to turn the
newlines into spaces. I tried using something like this:
text = text.Replace(Environment.NewLine, " ");
but it wasn't finding the newlines. I had to do
text = text.Replace("\n", " ");
What's going on here?
DaveMy guess is Environment.NewLine is actually '\r\n' while the text sent by a
page is just '\n'..
Girish Bharadwaj
http://msmvps.com/gbvb
"headware" <headware@.aol.com> wrote in message
news:e3f4b0ae.0409221023.51475a2@.posting.google.com...
> I have some multiline textboxes in a page and I'd like to turn the
> newlines into spaces. I tried using something like this:
> text = text.Replace(Environment.NewLine, " ");
> but it wasn't finding the newlines. I had to do
> text = text.Replace("\n", " ");
> What's going on here?
> Dave

Newlines in Datagrid

I have a very simple Datagrid with one bound field. The field has
Environment.NewLines in it. When the datagrid is rendered, they don't
appear.
I have tried a few of different ways to get them to appear:
1.) Replace Environment.NewLine with <br> before saving to the
database.
2.) Replace Environment.NewLine with </br> before saving to the
database.
Neither of these work because ASP.NET just ends up printing out the
literal <br>, </br>.
Is there a way to replace the Environment.NewLines when the datagrid is
rendered? Alternatively, is there a specific value I should be saving
to get the Datagrid to properly render the <br>?Best solution for me is to create a template column
and then replace the ItemTemplate label with a multiline textbox..
We show addresses like that and it works.
HTH.
Gerhard
<chrismichaelgardner@.hotmail.com> wrote in message
news:1126037176.699190.204720@.z14g2000cwz.googlegroups.com...
>I have a very simple Datagrid with one bound field. The field has
> Environment.NewLines in it. When the datagrid is rendered, they don't
> appear.
> I have tried a few of different ways to get them to appear:
> 1.) Replace Environment.NewLine with <br> before saving to the
> database.
> 2.) Replace Environment.NewLine with </br> before saving to the
> database.
> Neither of these work because ASP.NET just ends up printing out the
> literal <br>, </br>.
> Is there a way to replace the Environment.NewLines when the datagrid is
> rendered? Alternatively, is there a specific value I should be saving
> to get the Datagrid to properly render the <br>?
>