Text wrapping in ASP. NET

Source: Internet
Author: User

ASP. NET users who have just started learning ASP. NET will encounter the problem of automatically wrapping when displaying a large number of content with line breaks. I am telling you how to solve this problem and learn together:
In VB. NET:
1 function htmlcode () function htmlcode (byval fstring)
2 If fstring <> "" then
3 fstring = Replace (fstring, CHR (13 ),"")
4 fstring = Replace (fstring, CHR (10) & CHR (10), "</P> <p> ")
5 fstring = Replace (fstring, CHR (10), "<br> ")
6 htmlcode = fstring
7 end if
8 end Function
9
Example:
Contenttxt. Text = htmlcode (Rs. Item ("newscontent "))
Note:. contenttxt is the label control, and Rs. Item ("newscontent") is the set of records read from the database table.
Above Code Detailed code can be found in my. Net Blog system.
In C:
Private string htmlcode (string tstring)
{
If (tstring! = NULL)
{
Tstring = tstring. Replace ("\ r", "<br> ");
Tstring = tstring. Replace ("","");
Return tstring;
}
Else
{
Return tstring = "NO content ";
}
}
Example:
This. contenttxt. Text = htmlcode (newstab. Rows [0] ["contenttxt"]. tostring ());
Note:. contenttxt is the label control; newstab. Rows [0] ["contenttxt"]. tostring () is the set of records read from the database table.
The above code can be found in my. Net News system.
Http://lixyvip.cnblogs.com/archive/2006/03/30/362593.html

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.