"PRE"-Style formatting in HTML Output or Label

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jun 14, 2006.

  1. 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
     
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jun 14, 2006
    #1
    1. Advertising

  2. 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.)
     
    Steven Cheng[MSFT], Jun 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rocky Moore
    Replies:
    7
    Views:
    1,769
    mikeb
    Jan 14, 2004
  2. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,090
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  3. Wladimir Borsov
    Replies:
    7
    Views:
    493
    Raymond Loman
    May 5, 2004
  4. Juha Nieminen
    Replies:
    3
    Views:
    1,175
    Juha Nieminen
    Feb 22, 2008
  5. Knut Krueger
    Replies:
    8
    Views:
    296
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page