ASP Classic Truncate string and show dots at the end
Article Entry Date: June 3,2023 @ 11:52:55 / Last Updated On: June 3,2023 @ 11:54:32
ASP Classic, how to truncate a string and add dots at the end.
I needed to cut the words down on our new website and tried to find a script I received about 15 years ago, but I could not find it.
Here is another way of doing it, which makes the code easier to read and manipulate than other ways.
What we are doing.
We have our string "LongString," which has 67 characters.
Next, we use LEN to check how many characters are in the string.
If over 45 characters, we will truncate the string.
To truncate the string, we will use. mid(trim(LongString),1, 45)
Else, if it is not over 45 characters, it will display the entire string.
Here is the full code example.