For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > June 2006 > Character Trim









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Character Trim
danielst.clair@gmail.com

2006-06-29, 7:04 pm

I'm pulling customer testimonials from an SQL database onto the
homepage of a site. I want to set a trim that will not allow more than
250 characters of the testimonial to show. Anything over 250 would be
cut of and replaced with "..." I already have a link below that will
take them to a page that displays all testimonials. Current code (a
little messy):

<td width="220" height="97" valign="top">
<span
class="style4">"<%=(Testimonials.Fields.Item("test_desc").Value)%>..."<br
/>
-
<%=(Testimonials.Fields.Item("test_name").Value)%></span></td>

I want to trim the "test_desc." Any Ideas?

Jared

2006-06-29, 7:04 pm

Daniel

The simplest method would be in your SQL string.

Use

Select SubString(test_desc,0,250) + '...' as test_desc_trimmed,
test_name from tblMyTable

Then change your html to point to the renamed field.

Jared


danielst.clair@gmail.com wrote:
> I'm pulling customer testimonials from an SQL database onto the
> homepage of a site. I want to set a trim that will not allow more than
> 250 characters of the testimonial to show. Anything over 250 would be
> cut of and replaced with "..." I already have a link below that will
> take them to a page that displays all testimonials. Current code (a
> little messy):
>
> <td width="220" height="97" valign="top">
> <span
> class="style4">"<%=(Testimonials.Fields.Item("test_desc").Value)%>..."<br
> />
> -
> <%=(Testimonials.Fields.Item("test_name").Value)%></span></td>
>
> I want to trim the "test_desc." Any Ideas?


Göran Andersson

2006-06-29, 7:04 pm

I assume that you would want to cut the text between two words. Here is
a method that does it's best to do that:

http://www.guffa.com/Programming_archive.asp?id=42


danielst.clair@gmail.com wrote:
> I'm pulling customer testimonials from an SQL database onto the
> homepage of a site. I want to set a trim that will not allow more than
> 250 characters of the testimonial to show. Anything over 250 would be
> cut of and replaced with "..." I already have a link below that will
> take them to a page that displays all testimonials. Current code (a
> little messy):
>
> <td width="220" height="97" valign="top">
> <span
> class="style4">"<%=(Testimonials.Fields.Item("test_desc").Value)%>..."<br
> />
> -
> <%=(Testimonials.Fields.Item("test_name").Value)%></span></td>
>
> I want to trim the "test_desc." Any Ideas?
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com