question about wrapping a string

J

Joe Reynolds

this is kinda off topic, but not totally.

i have an ASP page that pulls text from a database, stores it in a variable,
then uses <%= variable %> to write the text inside an html table. the
problem im having has to do with wrapping. if the line of text is longer
than the table (or column) is wide, then the whole table is blown apart and
grows to fit the data. i was hoping for an easy way to fix this with CSS but
the only thing i can find that works is the wordwrap tag that ONLY IE
supports! so unless someone here knows how i can deal with this in css/html,
i will have to look at the Len() of the string and if its over a certain
amount of characters ill have to insert a <br> at every Nth character. does
anyone have any ideas? my table might look like this:

<table width="500+>
<tr>
<td width="250">this is the text im concerned with</td>
<td></td>
</tr>
</table>

i want that <td> to stay at 250 wide no matter what! does anyone know how to
do this in css? and if not, can someone show me how i might insert <br>'s
into my string at every 20th character or so?

thanks
 
E

Evertjan.

Joe Reynolds wrote on 28 Sep 2006 in
microsoft.public.inetserver.asp.general:
this is kinda off topic, but not totally.

i have an ASP page that pulls text from a database, stores it in a
variable, then uses <%= variable %> to write the text inside an html
table. the problem im having has to do with wrapping. if the line of
text is longer than the table (or column) is wide, then the whole
table is blown apart and grows to fit the data. i was hoping for an
easy way to fix this with CSS but the only thing i can find that works
is the wordwrap tag that ONLY IE supports! so unless someone here
knows how i can deal with this in css/html, i will have to look at the
Len() of the string and if its over a certain amount of characters ill
have to insert a <br> at every Nth character. does anyone have any
ideas? my table might look like this:

<table width="500+>
<tr>
<td width="250">this is the text im concerned with</td>
<td></td>
</tr>
</table>

i want that <td> to stay at 250 wide no matter what! does anyone know
how to do this in css? and if not, can someone show me how i might
insert <br>'s into my string at every 20th character or so?

It is totally off topic, since it is a clientside css matter.

Please ask in a css NG.
 
J

Joe Reynolds

did you read the whole problem?
i asked for help with a string in ASP. how is that off topic? why dont you
go read the whole problem and respond again
 
E

Evertjan.

Joe Reynolds wrote on 28 Sep 2006 in
microsoft.public.inetserver.asp.general:
[please do not toppost on usenet. Corrected.]
did you read the whole problem?
i asked for help with a string in ASP. how is that off topic? why dont
you go read the whole problem and respond again

so if I ask ...
<% = "Goede morgen" %>
Please translate the text in English?
.... it is an asp problem?

No, your problem can and schould be tackled with css,
like my above example in
So please ask in news:comp.infosystems.www.authoring.stylesheets.

So as I answered that css is the solution,
the Q is totally off topic,
since the "if not" does not apply when there is an css solution,
as you stipulated yourself!

.... which should make your string unreadable anyway.
 
J

Joe Reynolds

please dont bottom post, it annoys most of us.

no, it cant be handled in CSS because IE is the only browser that supports
the necessary tag (you should do more research before you answer)

so, again, since i will be displaying text in a fixed width column, how can
i take a string, loop through the characters, and insert a <br> at a
specific character count? is that on topic enough for you?



Evertjan. said:
Joe Reynolds wrote on 28 Sep 2006 in
microsoft.public.inetserver.asp.general:
[please do not toppost on usenet. Corrected.]
did you read the whole problem?
i asked for help with a string in ASP. how is that off topic? why dont
you go read the whole problem and respond again

so if I ask ...
<% = "Goede morgen" %>
Please translate the text in English?
... it is an asp problem?

No, your problem can and schould be tackled with css,
like my above example in
So please ask in news:comp.infosystems.www.authoring.stylesheets.

So as I answered that css is the solution,
the Q is totally off topic,
since the "if not" does not apply when there is an css solution,
as you stipulated yourself!

... which should make your string unreadable anyway.
 
D

Dave Anderson

Joe said:
i want that <td> to stay at 250 wide no matter what! does anyone
know how to do this in css? and if not, can someone show me how
i might insert <br>'s into my string at every 20th character or
so?

Yes, and Evertjan is correct. This really is not an ASP issue. It is a
presentation issue.

You can solve your problem by nesting a DIV container inside the TD and
styling the DIV with "width:250px;". Alternately, you can try using the
fixed table layout:
http://www.w3.org/TR/CSS21/tables.html#fixed-table-layout

CSS2 also defines a "max-width" property, but (a) I don't think it is widely
implemented, and (b) it probably suffers the same problem when applied to
table cells:
http://www.w3.org/TR/CSS21/visudet.html#propdef-max-width
 
J

Joe Reynolds

hey thank you.
unfortunately the div method doesnt work.

so now since i need an asp solution.... LOL

how can i loop through the string and insert a <br> every 20th character?
any ideas?
 
D

Dave Anderson

[please do not toppost]

Joe said:
please dont bottom post, it annoys most o
f us. no, it cant be handled in CSS becau
se IE is the only browser that supports t
he necessary tag (you should do more rese
arch before you answer)

so, again, since i will be displaying tex
t in a fixed width column, how can i take
a string, loop through the characters, an
d insert a <br> at a specific character c
ount? is that on topic enough for you?

Is that really what you want your text to look like? Rather unreadable, if
you ask me. But I guess there is no stopping you from doing this:

for (
var a=[], i=0;
i<variable.length;
a.push(variable.substring(i,i+=20))
)

output = a.join("<br>")
 
E

Evertjan.

Joe Reynolds wrote on 28 Sep 2006 in
microsoft.public.inetserver.asp.general:
please dont bottom post, it annoys most of us.

You are wrong, depending on what you mean with "us".

I did not ask you [politely] not to toppost,
as it is against usenet netiquette.

I did not ask you to bottompost.

Bottom posting is not the alternative of topposting,
no, it cant be handled in CSS because IE is the only browser that
supports the necessary tag

You are wrong, it can be.
What "tag" are you talking about? style='' ?
(you should do more research before you answer)

It seems to me, you, as the asking party, you could be more polite,
when people try to answer you, even if you do not like the answer,
thinking you know better.

Why were you asking about css anyway,
when you are so sure that is not the answer?
 
G

Guest

actually, bottom posting does indeed annoy 50% of "us", and by us i mean the 50% of newsgroup users that like to "top post" because it is more natural, it is how email works, and it is the default for most news readers. but i dont imagine youll get into this discussion for the millionth time. it is a preference. mine is different than yours, learn to live with it.

as for the style tag, i am referring to the IE only tag, "word-wrap: break-word" which will wrap text once it reaches the limit of the container it is in. other than that, as far as i know there is nothig else. a DIV tag would work, unless its a string with no spaces, then that too fails.

so what is your solution?




Evertjan. said:
Joe Reynolds wrote on 28 Sep 2006 in
microsoft.public.inetserver.asp.general:
please dont bottom post, it annoys most of us.

You are wrong, depending on what you mean with "us".

I did not ask you [politely] not to toppost,
as it is against usenet netiquette.

I did not ask you to bottompost.

Bottom posting is not the alternative of topposting,
no, it cant be handled in CSS because IE is the only browser that
supports the necessary tag

You are wrong, it can be.
What "tag" are you talking about? style='' ?
(you should do more research before you answer)

It seems to me, you, as the asking party, you could be more polite,
when people try to answer you, even if you do not like the answer,
thinking you know better.

Why were you asking about css anyway,
when you are so sure that is not the answer?
 
E

Evertjan.

wrote on 29 Sep 2006 in microsoft.public.inetserver.asp.general:
actually, bottom posting does indeed annoy 50% of "us",

No matter, who was talking or doing bottom posting?
And did you do a survey?
How did you reach this 50%?
and by us i
mean the 50% of newsgroup users that like to "top post" because it is
more natural, it is how email works,

So you think posting in usenet is email? Strange.

"Natural", that argumant n the negative goes way back in Europe.
and it is the default for most news readers.

Not at all IMHO.
How many newsreaders did you inspect?
How do you measure "default"?
And would that be a valid argument?
but i dont imagine youll get into this discussion for
the millionth time. it is a preference. mine is different than yours,

I am not discussing, I only politely ask not to toppost, because it is
against usenet netiquette, backed by an experience of usenet that is
twice as long as the web.
learn to live with it.

If you are happy, why do you respond?
as for the style tag, i am referring

I do not know who "I" is, as you are not identifying yourself.
Did you post earlier in this thread?
to the IE only tag, "word-wrap:
break-word" which will wrap text once it reaches the limit of the
container it is in. other than that, as far as i know there is nothig
else. a DIV tag would work, unless its a string with no spaces, then
that too fails.

so what is your solution?

My advice in this ASP NG is: ask in a css NG. It is off topic here.
 
B

Bob Lehmann

how can i loop through the string and insert a <br> every 20th character?
any ideas?

How is that going to look if the viewer has their font size set differently
than yours?

Bob Lehmann
 
A

Anthony Jones

Joe Reynolds said:
this is kinda off topic, but not totally.

i have an ASP page that pulls text from a database, stores it in a variable,
then uses <%= variable %> to write the text inside an html table. the
problem im having has to do with wrapping. if the line of text is longer
than the table (or column) is wide, then the whole table is blown apart and
grows to fit the data. i was hoping for an easy way to fix this with CSS but
the only thing i can find that works is the wordwrap tag that ONLY IE
supports! so unless someone here knows how i can deal with this in css/html,
i will have to look at the Len() of the string and if its over a certain
amount of characters ill have to insert a <br> at every Nth character. does
anyone have any ideas? my table might look like this:

<table width="500+>
<tr>
<td width="250">this is the text im concerned with</td>
<td></td>
</tr>
</table>

i want that <td> to stay at 250 wide no matter what! does anyone know how to
do this in css? and if not, can someone show me how i might insert <br>'s
into my string at every 20th character or so?

thanks

Have you tried the style table-layout:fixed on the table? can't remember if
this is a standard or not.

It seems inconceivable to me that a solution can't be found to this using
Standard CSS styles. Which is probably why we aren't forth coming with an
'ASP' solution. If you haven't already done so you might consider posting
this problem to a more HTML/CSS oriented group where people who eat and
drink CSS all day hang out. At least you should be able to procure a
definitive "no it can't be done" before writing an ASP workaround which is
likely to fall short anyway.
 
J

Joe Reynolds

yeah, its just a shame that as soon as someone comes here and asks for help
the first thing they get is an arrogant non english speaking person going
over the whole top-posting thing yet again
 
B

Bob Lehmann

What I'm getting at is that the font size may cause the text wrap in
addition to the <br>s the OP is trying to implement in his dopey solution.

Font - medium....

blah stupid idea blah.... 20thWord<br>
blah blah blah

Font - large.....
blah stupid idea
blah.... 20thWord<br>
blah blah blah

Bob Lehmann
 
B

Bob Lehmann

Right, <br> is a hard linebreak

Right. That is what the OP is trying to accomplish. He's vainly trying to
format his text using <br> so lines don't exceed his <td> width.

What he's come to realize, is that normal text would wrap on its own, so now
he's figured out that his <td> has room for a 40 character string, and is
trying to limit each "word" to 40 characters - another dopey solution - so
there are enough "words" to wrap.

Bob Lehmann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,251
Members
46,850
Latest member
Brightrs

Latest Threads

Top