Displaying Multi line wrapped text in web form
Posted on 2/4/2010 6:29:56 AM
in #ASP.NET 2.X
Hi,/P>
Many a times there is requirements for us to display text in multi-line in web pages. The first try that most of the people do is by giving a fixed width to the label. But this never works.
Height and Width works only for block level element. Label is an inline element and hence setting width does not work./P>
/o:p>/P>
What you can instead do is use a textbox with CSS that will make it looks like a label. To do this we need to set the following properties.
/P>
Wrap = true; rows = 5 (change this number as per your need.) ReadOnly = true TextMode = multiline (you need this to have multiple lines) BorderStyle = None BorderWidth = 0
Also when setting the text property, you should replace all the <Br> tags to new Line characters./P>
TextBox1.Text.Replace(Environment.NewLine, "<br>");
Vikram/P>
|