Question

Locked

How do you save text box input in SQL and redisplay in label?

By brian ·
I have a SQL DB with column that is called letter and set to TEXT as the type. I want to be able to enter in a multiline textbox the letter (including returns and whatnot) then save it to the DB and when I load a page, get it to display the saved field text correctly with all of the returns and whatnot. Basically heres an example: <retn> denotes where Enter is pressed

Entered into the textbox
Hi,<retn>
how are you? I am well, just trying to figure this out.<retn>
have a nice day!

When read from DB, this is what is shown written to the label:
hi,how are you? I am well, just trying to figure this out.Have a nice day!

I notice that in the DB Table, it puts in two square boxes or somehting like that where Enter has been pressed. I am using this for an internal automated e-mail that I have created, but need this last piece to automate it from our user DB. Help is appreciated!!!!

THUMBS FOR HELPFUL ANSWERS!!

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Most label components aren't multi line

by Tony Hopkinson In reply to How do you save text box ...

Use a textbox intead. Just set readonly to true
also there might be an AcceptReturns propety might be worrth looking at that as well, should be true as well.
all depends on what you are using, which you didnlt mention.

...

Collapse -

Reponse To Answer

by brian In reply to Most label components are ...

Using VB.net (yes, helpful information to give hehe). When I write this to the page, I don't want the person who is receiving this to see a text box. If I tell it to return in a textbox, it does work though (trying to pull this information back in HTML format somehow if possible just only knew that i could write the text to a label). Any other ideas?

Collapse -

So, can we assume the DB is Access or what?

by seanferd In reply to How do you save text box ...

Or did you write a DB from scratch in vb.net?

Collapse -

Reponse To Answer

by brian In reply to So, can we assume the DB ...

DB is SQL, using VB.net to code in. Connecting to SQL to get input and redisplay.

Collapse -

Hmm I stand corrected but confused

by Tony Hopkinson In reply to How do you save text box ...

Labels do cope with multi line
Label.Text = "Fred\r\nBloggs";
works fine, displays ok if autosize is true as well.

Hmmm where did your mention of HTML come from? If you you are converting to and from, white space would be stripped by default.

Collapse -

Reponse To Answer

by brian In reply to Hmm I stand corrected but ...

My though was since this is going to be an aspx page coded in VB.net, to redisplay with response.write to the label and do a find and replace for whatever the boxes stand for as <br> in response.write....code ex:
dim theinfo as string
dr(info)
find replace string here to replace the square boxes written into the db where the line breaks are
theinfo = the find and replace of dr(info)
html +="<table><tr><td>" & theinfo & "</td></tr></table>"
label = response.write(html)

The problem is, I don't know what the square boxes written stand for. I will look at what you have said though, it sounds like it would be a lot easier to do than a find a replace and re-write the info...etc

Collapse -

The square boxes

by Tony Hopkinson In reply to How do you save text box ...

are carriage return and line feed \r\n

Thing is they get replaced with a space by html, this will help
http://www-sul.stanford.edu/tools/tutorials/html2.0/whitespace.html

Collapse -

The square boxes are

by Tony Hopkinson In reply to How do you save text box ...

\r\n chars 13 and 10 carriage return and line feed.
getting you content from response.write gives you HTML where whitespace is considreed insignificant so they get replaced by a single space.
That's why your lable is not didplaying the line breaks.
Quick way is to use the pre tag, anything bracketed by those is left alone by the html parser.
Wrap them drirectly around the text fropm the editbox though. Everything after pre to /pre will be output as it, including mark up.

Back to Software Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums