A small lesson

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.