"PRE"-Style formatting in HTML Output or Label

G

Guest

I'm taking text from a multi-line TextBox into a database. Then, on other
pages, I'm displaying that text as read-only. But the problem is, when I set
the Text property of a Label control to that text, all the carriage returns
and other text-based formatting goes away because it's just dumping HTML.

Is there a way to set the display of a control like a Label to do the
old-fashioned "PRE" thing where it displays returns, spaces, etc.?

Alex
 
S

Steven Cheng[MSFT]

Hi Alex,

I've just replied your another thread about replacing the newline chars
with html newline chars <br/>, not sure which approach you'll chose finally
(replace or use <pre> element). The "pre" element is still available and
you can put a <pre> element around your label control or directly around
databinding expression (if not use label). e.g.

==============
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>

<pre>
<asp:Label ID="lblCategoryName" runat="server" Text='<%#
Eval("Description") %>'></asp:Label>
</pre>
</ItemTemplate>
</asp:Repeater>
==================

Hope this also helps.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top