Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Webskater
Starting Member
19 Posts |
Posted - 2009-10-29 : 06:11:44
|
| My front end is a .Net web application. Users can enter text (which will subsequently be used as the 'body' text in an email) in a custom 'rich text box' in the browser. Something like the box I am typing in now - where you can format the text with html markup.The custom box in question - let's call it HTMLBox1 - has these methods ... HTMLBox1.Text and HTMLBox.PlainThe first method gives you the html of what is entered in the box. The second method is supposed to give you plain text.I save the html text and the plain text in separate text fields in a SQL Server 2008 database.For example: The data entered in the rich text box might be ...Dear Customer,We'd like to invite you to a seminar etc.In the database field that stores the HTML version of the text, this might get stored as<p>Dear Customer,<br />We'd like to invite you to a seminar</p>In the database field that stores the PLAIN version of the text, this is getting stored as:Dear Customer, & n b s p; We'd like to invite you to a seminarThe custom Rich Text Box is outputting the html markup for a space (which I have put spaces in above so it shows) in what is supposed to be the PLAIN text output. Later a web service retrieves the data and sends emails using the data as the body of the email. (The .Net smtpClient sends two versions of the email, an HTML version and an alternate PLAIN version.) Most people who receive the email, who view it as Plain text, seem to see it okay. Most email clients seem to translate the html markup for a space into a carriage return.But, some users - who are viewing their emails as Plain text - are complaining that they see the html markup.So, my question is, when the 'Plain Text' version of whatever is entered in the Rich Text box is being written to the database, how can I replace the html markup for a space with a carriage return that, when the data is subsequently retrieved and sent as the body of an email, will contain a carriage return that all email clients are happy with?As an aside, I note that when I store data entered into a <textarea> in the front end into a text field in SQL Server, if I look at the text (using the example above) the data in the SQL Server Text field looks like this:Dear Customer, We'd like to invite you to a seminarIf I retrieve this data and display it in a web browser, it displays like this:Dear Customer,We'd like to invite you to a seminarIf you View Source in the browser there is a '<br />' after the comma in the first line - to give you your line feed.But, what is being stored in SQL Server that is being returned to a front end, that means the front end says 'Ahh, I need to put a '<br />' here. If you look in the SQL Server text field there are no characters showing that would indicate a carriage return (or line feed) is being stored. I'm baffled. How does the front end know there is a carriage return (or line feed) embedded in what is being returned from the database.Thanks for any help. |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-10-29 : 12:55:09
|
| maybe try nvarchar(max) instead of text?http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-31 : 02:07:52
|
| you wont be able to see effect of carriage returns in sql server table unless you view results as text in query analyser |
 |
|
|
|
|
|
|
|