hyphen in hyperlink causing unwanted break in text line

J

Joe Stateson

I have a template field that contains filenames that are (or can be) on a
unix system. The hypen (and others) is a valid filename character in unix.
When I display the name of the file I get an unwanted break and the text
wraps at the hyphen.

NavigateUrl bound to Eval("file_name","//acqlib/data/{0:c}") launches the
file just fine since there is nothing wrong with the '-' on the linux system
which is the acqlib server.

But binding "Text" as in
Eval("file_name","{0:c}") causes 3-4 rows to be displayed in the hyperlink
shown in the gridview. I assume this is because the hypen is interpreted as
a line break???

Is there a way to fix this in the IDE using Eval? I managed to get it
working using the RowDataBound callback as in ...

hl = (HyperLink)e.Row.Cells[idFilename].FindControl("hl4filename");
hl.Text = e.Row.Cells[idFilename].Text.ToString()..Replace('-','_')

Maybe there is a better way that does not involve interpreting any
characters such as '-'?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Joe said:
But binding "Text" as in
Eval("file_name","{0:c}") causes 3-4 rows to be displayed in the
hyperlink shown in the gridview. I assume this is because the hypen is
interpreted as a line break???

No, it's because the hyphen is interpreted as a hyphen. A line break is
allowed after a hyphen, just as with a space.
 
N

Nathan Sokalski

My recommendation would be to use the CSS property white-space, as in the
following:

<a style="white-space:nowrap;">testing-testing</a>

I tested this in IE (it should work the same in other browsers since it's
CSS, but you never know) by including the following in my HTML file:

<div style="width:10px;"><a
style="white-space:nowrap;">testing-testing</a></div>

Notice that the div has a specified width of 10px, which would normally
cause the text to wrap, but because of the white-space:nowrap; CSS property
it is prevented from wrapping. You can test this out by removing the
white-space:nowrap; from the style attribute. Hopefully this helps.
 
J

Joe Stateson

Nathan Sokalski said:
My recommendation would be to use the CSS property white-space, as in the
following:

<a style="white-space:nowrap;">testing-testing</a>

I tested this in IE (it should work the same in other browsers since it's
CSS, but you never know) by including the following in my HTML file:

<div style="width:10px;"><a
style="white-space:nowrap;">testing-testing</a></div>

Notice that the div has a specified width of 10px, which would normally
cause the text to wrap, but because of the white-space:nowrap; CSS
property it is prevented from wrapping. You can test this out by removing
the white-space:nowrap; from the style attribute. Hopefully this helps.

Thanks Nathan, that worked when I put it in the style for the hyperlink. I
first tried it on the table that the hyperlinks are in but it had to be
specified on the hyperlink style itself. I did not realize that a dash was
treated the same as white space.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top