How to make your ASP.Net label multiline (how to wrap text in your label)

First, sorry for the absence. It gets a bit busy in life and work. Not to mention getting up to speed on the 2.0 a big rush. All good things, but leave little time for fun stuff.

With that said, I would like to offer some tips to help you with ASP.Net page format. Getting a multiline label in the specified width. Now many of you know this trick, but I always have to recall the trick every time I need it, so this post could be a reference for you as well.

The trick actually is - Do not use labels. Use a textbox instead. Because all controls inherit from the same base class, text boxes and labels are very similar as well. But only the textbox has the multiline capability.

Once you have a textbox on your page the trick is to make it look like a label for end users. To do this, you need to set the following properties (this is the part I never remember):

Wrap = true; (clear)
row = {some number greater than 0} (I use the property line than the high property because it tends earier to get the right format)
ReadOnly = true (makes sense, right)
Textmode = multiline (or there is no real reason to wrap text ...)
BorderStyle = None
BorderWidth = 0

Those last two actually VERY important, and here is why. They get rid of that pesky border that you see around the text box. Border which is a common visual signal for the end user who says "ENTER INFO HERE!". If you leave the border to expect a lot of phone calls from people saying "web page is damaged it will not let me enter the text .."

Postingan populer dari blog ini

vb6 msflexgrid

Tutorial Visual Basic 6.0 : Listbox in VB6

Select Single Cell in MSHFlexgrid