Saturday, March 24, 2012

text overflow ==> "..."

Anyone know of a way, or a control, which would allow me to clip text with a
"..." displayed at the end?

We have a product comparison page, with products lied up side by side... one
of the fields displayed is the manufacturer, and some of them have VERY long
names, so id like to when the name is long, convert it from "Mr Joe Shmoes
Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of having
it crunch all the other products to the side.

Thanks in advance,
- Eidolon.What database are you using? This can be done directly in your SQL or Stored
Procedure.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Eidolon" <eidolonivanovich@.yahoo.com> wrote in message
news:OCaiU6$9DHA.1392@.tk2msftngp13.phx.gbl...
> Anyone know of a way, or a control, which would allow me to clip text with
a
> "..." displayed at the end?
> We have a product comparison page, with products lied up side by side...
one
> of the fields displayed is the manufacturer, and some of them have VERY
long
> names, so id like to when the name is long, convert it from "Mr Joe Shmoes
> Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of
having
> it crunch all the other products to the side.
> Thanks in advance,
> - Eidolon.
This is an ASP example but the same principle/idea will work
http://www.darkfalz.com/1076/

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com

"Eidolon" <eidolonivanovich@.yahoo.com> wrote in message
news:OCaiU6$9DHA.1392@.tk2msftngp13.phx.gbl...
> Anyone know of a way, or a control, which would allow me to clip text with
a
> "..." displayed at the end?
> We have a product comparison page, with products lied up side by side...
one
> of the fields displayed is the manufacturer, and some of them have VERY
long
> names, so id like to when the name is long, convert it from "Mr Joe Shmoes
> Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of
having
> it crunch all the other products to the side.
> Thanks in advance,
> - Eidolon.
One idea is to test for length, as such and take a subset of the string.

string longname;

if(longname.Length > 300)
{
longname = longname.Substring(0,299);
}

"Eidolon" <eidolonivanovich@.yahoo.com> wrote in message
news:OCaiU6$9DHA.1392@.tk2msftngp13.phx.gbl...
> Anyone know of a way, or a control, which would allow me to clip text with
a
> "..." displayed at the end?
> We have a product comparison page, with products lied up side by side...
one
> of the fields displayed is the manufacturer, and some of them have VERY
long
> names, so id like to when the name is long, convert it from "Mr Joe Shmoes
> Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of
having
> it crunch all the other products to the side.
> Thanks in advance,
> - Eidolon.
If Len(theString) > 10 then
theString = Left(10, theString) & "..."
End If

"Eidolon" <eidolonivanovich@.yahoo.com> wrote in message
news:OCaiU6$9DHA.1392@.tk2msftngp13.phx.gbl...
> Anyone know of a way, or a control, which would allow me to clip text with
a
> "..." displayed at the end?
> We have a product comparison page, with products lied up side by side...
one
> of the fields displayed is the manufacturer, and some of them have VERY
long
> names, so id like to when the name is long, convert it from "Mr Joe Shmoes
> Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of
having
> it crunch all the other products to the side.
> Thanks in advance,
> - Eidolon.
Thank you to everyone who has answered thus far. None of these solutions are
quite what i meant though.

In the Windows API, there is this function PathCompactPath, defined in
SHLWAPI.dll, where you can pass in the pixel width you need a path to fit
in, and it will shorten it as it needs to to fit in the desired length.

I am looking for something similar. I have a table with a variable number of
columns, each column representing a product. The first row in each column is
the manufacturers name. i want all the columns to be the same width across
the page, so i set them in code each to
<code>width='<%=Floor(100/NumCols)%>%'.
When i get one of these really long names though, it blows that column's
width way up, and crowds the other ones off to the side. I want to be able
to have the mfg name be dynamically truncated to fit in the specified column
width (probably in pixels?). Now i think of it, this would likely be more a
client-side scripting thing.

Any ideas, or solutions, appreciated.
Thanks in advance,
- Aaron.

"Scott M." <s-mar@.BADSPAMsnet.net> wrote in message
news:uRBsplA%23DHA.3648@.TK2MSFTNGP09.phx.gbl...
> If Len(theString) > 10 then
> theString = Left(10, theString) & "..."
> End If
>
> "Eidolon" <eidolonivanovich@.yahoo.com> wrote in message
> news:OCaiU6$9DHA.1392@.tk2msftngp13.phx.gbl...
> > Anyone know of a way, or a control, which would allow me to clip text
with
> a
> > "..." displayed at the end?
> > We have a product comparison page, with products lied up side by side...
> one
> > of the fields displayed is the manufacturer, and some of them have VERY
> long
> > names, so id like to when the name is long, convert it from "Mr Joe
Shmoes
> > Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of
> having
> > it crunch all the other products to the side.
> > Thanks in advance,
> > - Eidolon.
A possibility:
In the graphics namespace, there is a MeasureString method, that you can use
to
get the pixel-length of a string (using a specific font).
You could measure your name. If it shorter than you want to allow, no
problem,
else shorten the name until it fits.

Hans Kesting

"Eidolon" <eidolonivanovich@.yahoo.com> wrote in message
news:%239GJSdh%23DHA.1268@.TK2MSFTNGP12.phx.gbl...
> Thank you to everyone who has answered thus far. None of these solutions
are
> quite what i meant though.
> In the Windows API, there is this function PathCompactPath, defined in
> SHLWAPI.dll, where you can pass in the pixel width you need a path to fit
> in, and it will shorten it as it needs to to fit in the desired length.
> I am looking for something similar. I have a table with a variable number
of
> columns, each column representing a product. The first row in each column
is
> the manufacturers name. i want all the columns to be the same width across
> the page, so i set them in code each to
> <code>width='<%=Floor(100/NumCols)%>%'.
> When i get one of these really long names though, it blows that column's
> width way up, and crowds the other ones off to the side. I want to be able
> to have the mfg name be dynamically truncated to fit in the specified
column
> width (probably in pixels?). Now i think of it, this would likely be more
a
> client-side scripting thing.
> Any ideas, or solutions, appreciated.
> Thanks in advance,
> - Aaron.
>
> "Scott M." <s-mar@.BADSPAMsnet.net> wrote in message
> news:uRBsplA%23DHA.3648@.TK2MSFTNGP09.phx.gbl...
> > If Len(theString) > 10 then
> > theString = Left(10, theString) & "..."
> > End If
> > "Eidolon" <eidolonivanovich@.yahoo.com> wrote in message
> > news:OCaiU6$9DHA.1392@.tk2msftngp13.phx.gbl...
> > > Anyone know of a way, or a control, which would allow me to clip text
> with
> > a
> > > "..." displayed at the end?
> > > > We have a product comparison page, with products lied up side by
side...
> > one
> > > of the fields displayed is the manufacturer, and some of them have
VERY
> > long
> > > names, so id like to when the name is long, convert it from "Mr Joe
> Shmoes
> > > Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of
> > having
> > > it crunch all the other products to the side.
> > > > Thanks in advance,
> > > - Eidolon.
> >

0 comments:

Post a Comment