Today, when I was working on a project, I found a previously strange problem: there is a textbox multi-line text box to save the remarks. Of course, when I submit the remarks to the data, it can also contain line breaks and other labels. When the page is displayed, you must also mark these items for display.
But these simple tags make me have trouble. When I insert a database, I use server. htmlencode () method. Server is used for display. htmldecode (), but this does not work. Later, I was on the server. change htmlencode () to server. htmlencode (). replace ("/N", "<br>"), and then return decode when the display is displayed. The result still ends with a failure. Finally, check the database and find that, the data I inserted is not marked with a line break in the line feed, so the problem occurs only when it is displayed. The data type of this column field in the database is text. I clearly remember that if you add a line break in sqlserver2000, you will be able to see your line feed results at the corresponding location in the database, but why does sqlserver2005 fail?
After careful debugging and analysis, the root cause was found. When the database was inserted,/N was replaced with invalid characters, so the database could not find the line break, so I processed "// n" as follows, and everything was done.
We can learn from this, and then do it later.ProgramYou must start from the actual situation, rather than relying on experience! Haha!