Insert line break in text through code

  • Thread starter Thread starter Julia B
  • Start date Start date
J

Julia B

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
 
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.
 
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
 
Julia B said:
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

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
 
Ahh yes, didnt switch my thinking... used to C#, Environment.NewLine should
do the same thing.
 
Back
Top