Insert line break in text through code

Hi all

I've got a bit of code that inserts some text into a text field on a webform
under certain circumstances. The text needs some line breaks in it. This is
what I've done.

Me.OptionalNotesTB.Text = _
"- Unless otherwise offered in this quote no System Data
Requirement Lists " + _
"or other technical documentation is included. " + _
"Should these be required then we would be pleased to quote
for them separately. <br>" + _
"- Stock subject to prior sales. <br>" + _
"- Delivery charges will apply where appropriate. <br>" + _
"- The company has a minimum order charge of $250.00."

Unfortunately this doesn't seem to work. The text displays as follows:

"- Unless otherwise offered in this quote no System Data Requirement Lists
or other technical documentation is included. Should these be required then
we would be pleased to quote for them separately. <br>- Stock subject to
prior sales. <br- Delivery charges will apply where appropriate. <br- The
company has a minimum order charge of $250.00."

How do I convert the <br> into a line break?

Thanks in advance.
Julia
JuliaB [ Di, 29 Januar 2008 13:45 ] [ ID #1918857 ]

RE: Insert line break in text through code

Line breaks with html... i.e. <br> only work with the literal control I
believe. What I have used in my code is \n, this is a line break that works
with text boxes and the like. Also you could use a resources file and type it
exactly how you want it but use Shift+Enter when you want a new line.

"Julia B" wrote:

> Hi all
>
> I've got a bit of code that inserts some text into a text field on a webform
> under certain circumstances. The text needs some line breaks in it. This is
> what I've done.
>
> Me.OptionalNotesTB.Text = _
> "- Unless otherwise offered in this quote no System Data
> Requirement Lists " + _
> "or other technical documentation is included. " + _
> "Should these be required then we would be pleased to quote
> for them separately. <br>" + _
> "- Stock subject to prior sales. <br>" + _
> "- Delivery charges will apply where appropriate. <br>" + _
> "- The company has a minimum order charge of $250.00."
>
> Unfortunately this doesn't seem to work. The text displays as follows:
>
> "- Unless otherwise offered in this quote no System Data Requirement Lists
> or other technical documentation is included. Should these be required then
> we would be pleased to quote for them separately. <br>- Stock subject to
> prior sales. <br- Delivery charges will apply where appropriate. <br- The
> company has a minimum order charge of $250.00."
>
> How do I convert the <br> into a line break?
>
> Thanks in advance.
> Julia
Ian [ Di, 29 Januar 2008 16:58 ] [ ID #1918883 ]

RE: Insert line break in text through code

Thanks Ian,

I've tried replacing <br> in my code with \n and it hasn't made any
difference other than \n displays in the text box.

I don't understand what you mean by using a resources file?

Julia

"Ian" wrote:

> Line breaks with html... i.e. <br> only work with the literal control I
> believe. What I have used in my code is \n, this is a line break that works
> with text boxes and the like. Also you could use a resources file and type it
> exactly how you want it but use Shift+Enter when you want a new line.
>
> "Julia B" wrote:
>
> > Hi all
> >
> > I've got a bit of code that inserts some text into a text field on a webform
> > under certain circumstances. The text needs some line breaks in it. This is
> > what I've done.
> >
> > Me.OptionalNotesTB.Text = _
> > "- Unless otherwise offered in this quote no System Data
> > Requirement Lists " + _
> > "or other technical documentation is included. " + _
> > "Should these be required then we would be pleased to quote
> > for them separately. <br>" + _
> > "- Stock subject to prior sales. <br>" + _
> > "- Delivery charges will apply where appropriate. <br>" + _
> > "- The company has a minimum order charge of $250.00."
> >
> > Unfortunately this doesn't seem to work. The text displays as follows:
> >
> > "- Unless otherwise offered in this quote no System Data Requirement Lists
> > or other technical documentation is included. Should these be required then
> > we would be pleased to quote for them separately. <br>- Stock subject to
> > prior sales. <br- Delivery charges will apply where appropriate. <br- The
> > company has a minimum order charge of $250.00."
> >
> > How do I convert the <br> into a line break?
> >
> > Thanks in advance.
> > Julia
JuliaB [ Di, 29 Januar 2008 17:11 ] [ ID #1918886 ]

Re: Insert line break in text through code

"Julia B" <JuliaB [at] discussions.microsoft.com> wrote in message
news:96B8FE1A-820A-4ED1-8178-F14EAB9B4019 [at] microsoft.com...
> Thanks Ian,
>
> I've tried replacing <br> in my code with \n and it hasn't made any
> difference other than \n displays in the text box.
>
> I don't understand what you mean by using a resources file?
>
> Julia
>
> "Ian" wrote:
>
>> Line breaks with html... i.e. <br> only work with the literal control I
>> believe. What I have used in my code is \n, this is a line break that
>> works
>> with text boxes and the like. Also you could use a resources file and
>> type it
>> exactly how you want it but use Shift+Enter when you want a new line.
>>
>> "Julia B" wrote:
>>
>> > Hi all
>> >
>> > I've got a bit of code that inserts some text into a text field on a
>> > webform
>> > under certain circumstances. The text needs some line breaks in it.
>> > This is
>> > what I've done.
>> >
>> > Me.OptionalNotesTB.Text = _
>> > "- Unless otherwise offered in this quote no System
>> > Data
>> > Requirement Lists " + _
>> > "or other technical documentation is included. " + _
>> > "Should these be required then we would be pleased to
>> > quote
>> > for them separately. <br>" + _
>> > "- Stock subject to prior sales. <br>" + _
>> > "- Delivery charges will apply where appropriate. <br>"
>> > + _
>> > "- The company has a minimum order charge of $250.00."
>> >
>> > Unfortunately this doesn't seem to work. The text displays as follows:
>> >
>> > "- Unless otherwise offered in this quote no System Data Requirement
>> > Lists
>> > or other technical documentation is included. Should these be required
>> > then
>> > we would be pleased to quote for them separately. <br>- Stock subject
>> > to
>> > prior sales. <br- Delivery charges will apply where appropriate. <br-
>> > The
>> > company has a minimum order charge of $250.00."
>> >
>> > How do I convert the <br> into a line break?
>> >
>> > Thanks in advance.
>> > Julia

Since it appears you are using VB as language it does not know what \n is.
Use Environment.NewLine as the line break in your code and all should be
good.

Hope this helps
LS
Courtney [ Di, 29 Januar 2008 17:28 ] [ ID #1918891 ]

Re: Insert line break in text through code

Ahh yes, didnt switch my thinking... used to C#, Environment.NewLine should
do the same thing.

"Lloyd Sheen" wrote:

>
> "Julia B" <JuliaB [at] discussions.microsoft.com> wrote in message
> news:96B8FE1A-820A-4ED1-8178-F14EAB9B4019 [at] microsoft.com...
> > Thanks Ian,
> >
> > I've tried replacing <br> in my code with \n and it hasn't made any
> > difference other than \n displays in the text box.
> >
> > I don't understand what you mean by using a resources file?
> >
> > Julia
> >
> > "Ian" wrote:
> >
> >> Line breaks with html... i.e. <br> only work with the literal control I
> >> believe. What I have used in my code is \n, this is a line break that
> >> works
> >> with text boxes and the like. Also you could use a resources file and
> >> type it
> >> exactly how you want it but use Shift+Enter when you want a new line.
> >>
> >> "Julia B" wrote:
> >>
> >> > Hi all
> >> >
> >> > I've got a bit of code that inserts some text into a text field on a
> >> > webform
> >> > under certain circumstances. The text needs some line breaks in it.
> >> > This is
> >> > what I've done.
> >> >
> >> > Me.OptionalNotesTB.Text = _
> >> > "- Unless otherwise offered in this quote no System
> >> > Data
> >> > Requirement Lists " + _
> >> > "or other technical documentation is included. " + _
> >> > "Should these be required then we would be pleased to
> >> > quote
> >> > for them separately. <br>" + _
> >> > "- Stock subject to prior sales. <br>" + _
> >> > "- Delivery charges will apply where appropriate. <br>"
> >> > + _
> >> > "- The company has a minimum order charge of $250.00."
> >> >
> >> > Unfortunately this doesn't seem to work. The text displays as follows:
> >> >
> >> > "- Unless otherwise offered in this quote no System Data Requirement
> >> > Lists
> >> > or other technical documentation is included. Should these be required
> >> > then
> >> > we would be pleased to quote for them separately. <br>- Stock subject
> >> > to
> >> > prior sales. <br- Delivery charges will apply where appropriate. <br-
> >> > The
> >> > company has a minimum order charge of $250.00."
> >> >
> >> > How do I convert the <br> into a line break?
> >> >
> >> > Thanks in advance.
> >> > Julia
>
> Since it appears you are using VB as language it does not know what \n is.
> Use Environment.NewLine as the line break in your code and all should be
> good.
>
> Hope this helps
> LS
>
>
Ian [ Di, 29 Januar 2008 17:37 ] [ ID #1918892 ]

Re: Insert line break in text through code

That did the trick! Brilliant, thanks for both your help.

Julia

"Ian" wrote:

> Ahh yes, didnt switch my thinking... used to C#, Environment.NewLine should
> do the same thing.
>
> "Lloyd Sheen" wrote:
>
> >
> > "Julia B" <JuliaB [at] discussions.microsoft.com> wrote in message
> > news:96B8FE1A-820A-4ED1-8178-F14EAB9B4019 [at] microsoft.com...
> > > Thanks Ian,
> > >
> > > I've tried replacing <br> in my code with \n and it hasn't made any
> > > difference other than \n displays in the text box.
> > >
> > > I don't understand what you mean by using a resources file?
> > >
> > > Julia
> > >
> > > "Ian" wrote:
> > >
> > >> Line breaks with html... i.e. <br> only work with the literal control I
> > >> believe. What I have used in my code is \n, this is a line break that
> > >> works
> > >> with text boxes and the like. Also you could use a resources file and
> > >> type it
> > >> exactly how you want it but use Shift+Enter when you want a new line.
> > >>
> > >> "Julia B" wrote:
> > >>
> > >> > Hi all
> > >> >
> > >> > I've got a bit of code that inserts some text into a text field on a
> > >> > webform
> > >> > under certain circumstances. The text needs some line breaks in it.
> > >> > This is
> > >> > what I've done.
> > >> >
> > >> > Me.OptionalNotesTB.Text = _
> > >> > "- Unless otherwise offered in this quote no System
> > >> > Data
> > >> > Requirement Lists " + _
> > >> > "or other technical documentation is included. " + _
> > >> > "Should these be required then we would be pleased to
> > >> > quote
> > >> > for them separately. <br>" + _
> > >> > "- Stock subject to prior sales. <br>" + _
> > >> > "- Delivery charges will apply where appropriate. <br>"
> > >> > + _
> > >> > "- The company has a minimum order charge of $250.00."
> > >> >
> > >> > Unfortunately this doesn't seem to work. The text displays as follows:
> > >> >
> > >> > "- Unless otherwise offered in this quote no System Data Requirement
> > >> > Lists
> > >> > or other technical documentation is included. Should these be required
> > >> > then
> > >> > we would be pleased to quote for them separately. <br>- Stock subject
> > >> > to
> > >> > prior sales. <br- Delivery charges will apply where appropriate. <br-
> > >> > The
> > >> > company has a minimum order charge of $250.00."
> > >> >
> > >> > How do I convert the <br> into a line break?
> > >> >
> > >> > Thanks in advance.
> > >> > Julia
> >
> > Since it appears you are using VB as language it does not know what \n is.
> > Use Environment.NewLine as the line break in your code and all should be
> > good.
> >
> > Hope this helps
> > LS
> >
> >
JuliaB [ Di, 29 Januar 2008 17:52 ] [ ID #1918894 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » Insert line break in text through code

Vorheriges Thema: Is my approach right?
Nächstes Thema: [Personalizable(PersonalizationScope.User)]