tags:

views:

103

answers:

3

Hello, I have a basic question:

I am getting text data from a database and want to display in a label (x width, don't know if width is important but I guess it is) upto 5 lines of text (if in database the data is less then 5 lines all will be displayed).

Need to work with all borwsers.

Thanks for any help.

A: 

I don't think you can do that. It's like asking how long is a piece of string..... how long is 5 lines of text?

Now if you were to say something like 100 characters then you could get the Substring(0, 100) before assigning it to the label since I don't believe there is a way to specify the max length of the text of a label.

mezoid
So you're saying that I should count the number of chars that fit in one line of my label's width, and limit the text data to the number*5?
@yevenus yes, that might be one possible solution unless the width of your label is supposed to be able to be varied.
mezoid
+1  A: 

This will help you only if you are using jQuery. There is a plugin called expander for the sort of thing you want to do. But remember it will work with number of characters rather than lines.

TheVillageIdiot
A: 

Mezoid is correct but usually 5 lines of text should take between 350 to 400 characters. So you can do Subsstring(0, 350) and results should be good.

chikak