Click here to Skip to main content
15,921,113 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
how to adjust height of asp label control when data is too long
Posted
Comments
willempipi 6-Apr-11 9:11am    
What is the problem you face, and what do you want to achive?

If you specify the width property then label automatically wrap it and display multi lines. Note wrap works on the words of the sentences. But if a word with 1000 chars it can't wrap. Is that is your problem a long word?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Apr-11 18:43pm    
That's correct, my 5.
--SA
Set the label's height-width as much available. As long as the sentence/data can break and show, it will automatically wrap and show. If it exceed the area, it will get cut off.

For such cases, generally, the data length is checked and if found more than a certain length then the entire text is shown on hover of the label and the label txt itself is chopped off with an ellipses at the end.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Apr-11 18:45pm    
For a label? Hm. Do you mean absolute positioning? As for normal style the label will take as much space as needed. If you limit width, it will grow down (which is probably fine), isn't that so? (See Albin's Answer.)
--SA
Sandeep Mewara 7-Apr-11 1:01am    
No not absolute positioning. In general over all. For even a long word that is without a space (which would not break or move down and the whole UI can look messed up).

In case, growing down is also fine, as per usability, my suggestion on ellipses should be conisdered and implemented. UI looks good and everything in place.
Sergey Alexandrovich Kryukov 7-Apr-11 1:31am    
I see. If the long text with not chance to wrap (because there are not spaces) is involved, the ellipsis is good enough (I would suggest in different font/color). This is a well-known stylistic element, so if can be understood correctly. Well, my 5, after all.

However, how about a read-only edit box (input in terms of HTML)? It could be be of fixed or limited size, but the text would be scrollable if it is too long. Dont' you think it would be more clear?

--SA
Sandeep Mewara 7-Apr-11 2:39am    
Yep that was the point... overall consistency. BTW, virtual 5 ;) Haha. Its ok.

how about a read-only edit box (input in terms of HTML)?
An option for sure but I would not prefer it from UI and user intuitive prospective. It will just confuse someone.

Assume you have a form with a caption of a readonly textarea (the exact control you are talking of), it would not look good at all and based on normal experiences it would confuse user on why it's not a label or so and a textbox is there. How or when will it get enabled, etc.

What say?
Sergey Alexandrovich Kryukov 7-Apr-11 3:10am    
Materialized the vote, to certain extent :-)

Aha. Maybe you're right. It also depends on the overall design. This is a delicate matter.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900