views:

490

answers:

3

I'm trying to get the text within the ASP Hyperlink control to NOT wrap when it is placed within a html table as below:

<table style="width: 320px" class="noLines">
<tr><td style="width: 300px"> <asp:HyperLink Target="_self" ID="frmSuggest"  Text ="Click Click Click Click Click" Visible="false" runat="server"></asp:HyperLink> 
</td></tr>
<table>

I have tried adding a width property to the HyperLink and this does the trick unfortunatley it shifts all the other controls within this table by this width as well!

+1  A: 
<td style="white-space:nowrap;">
  <!-- You link here -->
</td>

Overrides though the width setting.

Greco
Unfortunatley this has the same effect as setting the width property in the Hyperlink control, and shifts all the other asp web controls within the table to right. The issue seems stem from the fact other web controls are defined within the same table?
well, then the only option is to trim the text for the hyperlink to a short version (maybe with 3 dots at the end), having the tooltip display the full text.
Greco
A: 

in addition to El Greco's answer, nobr tag is another option

<asp:HyperLink Target="_self" ID="frmSuggest" Visible="false" runat="server">
    <nobr>Click Click Click Click Click</nobr>
</asp:HyperLink>
Canavar
Thanks for the suggestion. The same issue occurs as before it pushes the other web controls within the html table to the right. Not sure why this is happneing?
I think your problem is about the design. maybe you can add an image/screenshot to your question, and we can easily understand your problem.
Canavar
A: 

i don't know if i understand you right, but here is a VB function that will trim a string without cutting words, you can convert it to c# here http://converter.telerik.com/

Function neatTrim( strToTrim, desiredLength ) '==== strToTrim = trim( strToTrim )

if len( strToTrim ) < desiredLength then
    neatTrim = strToTrim
    exit function
else
    if inStrRev( strToTrim, " ", desiredLength ) = 0 then
        strToTrim = left( strToTrim, desiredLength - 1 ) & "&#133;"
     else
        strToTrim = left( strToTrim, inStrRev( strToTrim, " ", desiredLength + 1 ) -1 ) & "&#133;" 'no carriage return here
    end if
end if

neatTrim = trim( strToTrim )
End Function