The long title is ended with a ellipsis in ASP.

Source: Internet
Author: User

During dynamic web page programming, if the article title is too long and exceeds the table width, the new line will be automatically wrapped, which will affect the layout of the webpage. Therefore, we usually extract a part of the characters in a fixed manner, and then use... .
Here, we will give a brief description based on the "Deep Space whole site system" program instance.

1. Principle:
Determine whether the length of an article exceeds the specified length. If the length exceeds the specified length, only the text of the specified length is displayed. Otherwise, the text is displayed completely.

2. involved functions:
For more information about function usage, see the VBScript function manual:
Len () returns the length of the string or the length of the variable in bytes.
Mid () returns the string starting from the nth character to take M characters. Its format is mid ("string", n, m ).
Left (): truncates the first part of a string.

<%
Title = RS ("content") 'assigns the database field value to a variable
I = 10' defines a fixed size of 10
If Len (title)> I then', if the text length is greater than the given value
Title = left (title, I) 'extracts the I-bit string from the front
Response. Write (Title &"...")
Else
Response. Write (title)
End if
%>

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.