Last post Dec 10, 2008 12:31 PM by Dergham
Jan 25, 2008 08:12 PM|Talk2Sachin|LINK
I would like to know how to set max length property for label control.
Basically I have a label control in my webform which displays data from description field in database.
The Description field can be very large in characters.
I want to display only 100 characters in the label at a time and beside that an image where in user would click on that image and then view all the characters
Any help from you guys would be appreciated
Jan 25, 2008 08:36 PM|vinz|LINK
Basically A label doesn't have a MaxLenth property.. why not use TextBox instead and set its styles using CSS to be look like a label..
Jan 25, 2008 08:45 PM|dotnetkode|LINK
//Get your description
Jan 25, 2008 08:51 PM|Talk2Sachin|LINK
Hi Thanks for the reply
Can u please provide me sample style sheet on the same
Jan 25, 2008 08:58 PM|Talk2Sachin|LINK
I am binding through aspx page
<asp:label id="lDesc" runat ="server" text = '<% Databinder.Eval(Container.DataItem,"Description") %>' > </asp.label>
how do use that function over here ?
Jan 25, 2008 10:55 PM|dotnetkode|LINK
You can try this.
<asp:label id="lDesc" runat ="server" text ='<%# (Eval("Description") .Length>=100) ? Eval("Description").SubString(0,100) :Eval("Description") %>'></asp:Label>
Jan 26, 2008 12:25 AM|Nick Kusters|LINK
//Get your description
...and be sure to put the full text in the .ToolTip property.
Jan 28, 2008 04:26 PM|Talk2Sachin|LINK
Hi Thank you very much for reply
Its working the only cache remaining is .. I need to show 3 dots ( ...) after the 1000 characters as an indication that the field contains more value ..
It is basically a concatenation of 3 dot characters after 1000 characters.
Thanks again for your help
Jan 28, 2008 04:36 PM|Nick Kusters|LINK
Here's a function to do this (wrote it here in the textbox)
public function CutOffString(Text as string, Length as integer) as string
dim result as string = string.empty
if not string.isnullorempty(text) andalso Length > 3 then
if text.length > Length then
result = text.substring(0,length -3) & "..."
Dec 10, 2008 12:31 PM|Dergham|LINK
hi guys i am using a listview control which has a label thats bound to the description filed in the database, as below
<asp:Label ID="HotelDescription" runat="server"
Text='<%# Eval("HotelDescription") %>'></asp:Label>
i would like to set the length of the label to show only 100 characters say, i dont want to show the full description which is long.
i prefer not to create another column in the database called short description to avaoid duplication.
please let me know the best way forward.