Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a multi line text box in windows form and i am using VB .NET.

When the user enters the data into the text box and saves, i am storing it as string data type in database.

The text box value i have stored in the database is used as mail body to send email to guest.

while i am storing and retrieving the text box value as string, even though the user enters the data in new line, multi line and with spaces, it is storing as continuous string.

What I have tried:

I am using

string body = textbox1.text

I want to store it as a html format in the database and to retrieve the same as in html format. so that i can send the email as in the format of the user entered data.


Thanks In Advance
Posted
Comments
Jochen Arndt 11-Dec-17 5:58am    
Your question is unclear:
Do you want to store the text as HTML or as entered (which it should do already)?

HTML ignores new line characters when being printed. To convert plain text to HTML, enclose the text by <p> tags and replace new line sequences with <br> tags after replacing reserved characters by the corresponding HTML entities.
F-ES Sitecore 11-Dec-17 6:05am    
Post the relevant code. Also are you assuming is it stored as one line because that is what appears in the email? Or do you know it is stored in one line as you are querying the database somehow?
Member 13142345 11-Dec-17 6:11am    
Sorry for the uncleared question...

i am posting the example data to textbox

i am entering the below data

We hope you enjoy the stay in our hotel. Looking forward to serve you

Hotel features:
542 rooms and suites.
Guestrooms overlooking lush terrace garden or Victoria Harbour.
Seven exclusively appointed Grand Club floors offering a private reception lounge, all day tea / coffee service, complimentary breakfast, evening cocktails with canapés.

Hotel features:
542 rooms and suites.
Guestrooms overlooking lush terrace garden or Victoria Harbour.
Seven exclusively appointed Grand Club floors offering a private reception lounge, all day tea / coffee service, complimentary breakfast, evening cocktails with canapés.

Hotel features:
542 rooms and suites.
Guestrooms overlooking lush terrace garden or Victoria Harbour.
Seven exclusively appointed Grand Club floors offering a private reception lounge, all day tea / coffee service, complimentary breakfast, evening cocktails with canapés.


the total data i am storing it as a string to the database . It is storing in a line and when i query the data and see the form it is all appearing in single line.

hope you understand
Jochen Arndt 11-Dec-17 6:52am    
Tip: Use the Reply button at comments. Then the poster of the comment you are replying to gets an email notification. So I just saw your comments by revisiting your question.

"the total data i am storing it as a string to the database . It is storing in a line and when i query the data and see the form it is all appearing in single line."

The string retrieved from the text box should contain new lines (provided that the text box is configured for multi line and accepting the enter key). When wrting that to the database, the new lines should be still there (in the database) and also when querying from the database.

How do you display the queried data (what kind of "form")? Have you tried writing it back to a text box?
Member 13142345 11-Dec-17 22:50pm    
Thanks for the Response Jochen. I have used the multiline textbox for the user to enter data and i have used nvarchar(MAX) to store the data into the database.
So, when displaying the stored data into the textbox it is displaying with spaces, new lines and paragraphs same as the entered data.

i have tried to send that data as email body to the user. But it was sent without new lines and paragraphs. can you help me to send the data with the user entered database, paragraph and spaces

Thanks in Advance

1 solution

Thank you all for your responses..
I got the solution by placing html code around the body using pre tag and set the isbodyhtml element attribute value to true
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900