Formatting Multiline Text

Discussion in 'ASP .Net' started by =?Utf-8?B?T3dlbiBSaWNoYXJkc29u?=, Aug 23, 2006.

  1. I have read several posts regarding formatting multiline text for rendering
    becuase vbCrLf needs to be converted to <br/> tags, and i need to do the
    same. My question is the best way to achieve this - One of my pages is using
    a detailview control on a Description datafield; what would be the best way
    for me to format the Description field before its rendered?

    Regards
    Owen
     
    =?Utf-8?B?T3dlbiBSaWNoYXJkc29u?=, Aug 23, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?T3dlbiBSaWNoYXJkc29u?=

    David Wier Guest

    do a replace on the Textbox text
    String.Replace(vbcrlf, "<br>")
    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://aspexpress.com



    "Owen Richardson" <> wrote in
    message news:...
    > I have read several posts regarding formatting multiline text for

    rendering
    > becuase vbCrLf needs to be converted to <br/> tags, and i need to do the
    > same. My question is the best way to achieve this - One of my pages is

    using
    > a detailview control on a Description datafield; what would be the best

    way
    > for me to format the Description field before its rendered?
    >
    > Regards
    > Owen
     
    David Wier, Aug 23, 2006
    #2
    1. Advertising

  3. Hi... I dont think i was really clear - i understand how to do the string
    replace but not where. In my example i was displaying a detailview control
    bound to my database, and trying to render the description field; Looking
    through the code i dont know where its appropriate to run this function; I am
    new to asp.net - I have created an template for my description field within
    it i have the following code:

    <asp:Label ID="Label2" runat="server" Text='<%# Bind("description")
    %>'></asp:Label>

    and i literally dont know what to do with it.... do I have to do something
    create a prerender function for Label2? if so how do i reference
    label2.Text....? Alternatively do i have another event on the DetailView
    control the page that i have to trap? I want to just change this one field in
    the most simple clean way possible.

    Kind Regards
    Owen

    "David Wier" wrote:

    > do a replace on the Textbox text
    > String.Replace(vbcrlf, "<br>")
    > --
    > David Wier
    > MVP/ASPInsider
    > http://aspnet101.com
    > http://aspexpress.com
    >
    >
    >
    > "Owen Richardson" <> wrote in
    > message news:...
    > > I have read several posts regarding formatting multiline text for

    > rendering
    > > becuase vbCrLf needs to be converted to <br/> tags, and i need to do the
    > > same. My question is the best way to achieve this - One of my pages is

    > using
    > > a detailview control on a Description datafield; what would be the best

    > way
    > > for me to format the Description field before its rendered?
    > >
    > > Regards
    > > Owen

    >
    >
    >
     
    =?Utf-8?B?T3dlbiBSaWNoYXJkc29u?=, Aug 23, 2006
    #3
  4. =?Utf-8?B?T3dlbiBSaWNoYXJkc29u?=

    Todd Guest

    There's several ways to do this, but try this. Add a function in the
    code behind, something like...


    Function MyFunc(MyVal as String) as String
    return Replace(MyVal, vbcrlf, "<br>")
    End Function

    Then on the aspx page itself, change your bind tag to....

    <asp:Label ID="Label2" runat="server" Text='<%#
    MyFunc(Eval("description") )%>'></asp:Label>

    Or if you have other things to convert, build a conversiob class and
    call the class from the function.

    HTH

    Todd
     
    Todd, Sep 19, 2006
    #4
    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. cw
    Replies:
    1
    Views:
    635
    James J. Foster
    Jun 27, 2003
  2. Michael Tanner

    Different fonts in multiline text box...

    Michael Tanner, Jul 25, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    650
    Steve C. Orr, MCSD
    Jul 25, 2003
  3. Stephan Bour
    Replies:
    2
    Views:
    7,215
    Stephan Bour
    Oct 28, 2003
  4. Chris
    Replies:
    2
    Views:
    6,251
    Chris
    Oct 26, 2004
  5. dale zhang
    Replies:
    8
    Views:
    455
    Tintin
    Nov 30, 2004
Loading...

Share This Page