tag, text goes outside parent border I have a strange problem, I have a datarepe...">

When using <pre class = "prettyprint-override"> tag, text goes outside parent <asp: label> border

I have a strange problem,

I have a datarepeater that reads some custom records from a database and then shows them in <asp:label>

..

My first problem was that when the text is read, everything is \n

discarded ..

so i use tag <pre>

to solve the problem. however ... a new problem has arisen .. now the text actually extends beyond the label.

<td width="630px" >
 <pre>
   <asp:Label ID="lblComments"  runat="Server" 
       width="630px" Text='<%#DataBinder.Eval(Container.DataItem, "Comments") %>'
       Style="font-size: larger">
   </asp:Label>
  </pre>
</td>

      

+2


source to share


3 answers


Yep, pre will just output text that has little or no relation to the page layout.

You must format text from the database to convert \ n to <br/>

s.



You should get away with something like:

<%# DataBinder.Eval(Container.DataItem, "Comments")
                   .ToString().Replace("\n", "<br />") %>

      

+6


source


<present> means additional line breaks have been added to the text.



You will have to shorten the length of the lines in the preformatted text.

+4


source


Use the css property " pre {white-space: normal;}

" Does this work?

+1


source







All Articles