Wednesday, March 23, 2011

Text Truncate with three dots

Most of the time I work with this via extension methods and display only number of characters of a string then adding 3 dots ...

On current project I need to display a text not limited by number of characters but by a specified width ...

I did it by applying a style on div as you see below:

<div style="overflow:hidden; text-overflow:ellipsis;white-space:nowrap">
<asp:Label ID="lblTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
</div>

If you need to do it programatically you can see this link, but I did not try it :

Hope it helps you all,
Inform me if you find any problem or a better way

No comments:

Post a Comment