Problem with free form text

Discussion in 'ASP .Net Web Controls' started by Gary Wardell, Jun 12, 2008.

  1. Gary Wardell

    Gary Wardell Guest

    Hi,

    I have a free form text file, call Notes.

    I want to be able to both display and edit and input this field in a
    DetailsView control. This would seem to be a natural for a multiline text
    box, but there doesn't seem to be one of these as a bound field in
    DesignView.

    The examples I've found all show using a Label in a Panel In an ItemTemplate
    to display the field and a Multiline Textbox in the EditItemTemplate.

    That all seems to work; so far so good and the page looks good.

    Now comes the rub.

    I want to be able to format the text with carrage returns.

    The Label control wants these to be rendered as <br />; but the textBox
    wants these rendered as CRLF.

    I find there is a OnPreRender even that looks like I could replace the crlfs
    with the proper new line sequence for the respective control.

    Problem is, how do I refernce the Label and Textbox fields burried in the
    templates in the DesignView from the PreRender event?

    In desperation I tried using the textbox in the ItemTamplate and that works,
    but the page looks a little funny having labels for all for the other fields
    and a textbox for this one.

    Gary
     
    Gary Wardell, Jun 12, 2008
    #1
    1. Advertising

  2. Gary Wardell

    Stan Guest

    On 12 Jun, 19:39, "Gary Wardell" <> wrote:
    > Hi,
    >
    > I have a free form text file, call Notes.
    >
    > I want to be able to both display and edit and input this field in a
    > DetailsView control.  This would seem to be a natural for a multiline text
    > box, but there doesn't seem to be one of these as a bound field in
    > DesignView.
    >
    > The examples I've found all show using a Label in a Panel In an ItemTemplate
    > to display the field and a Multiline Textbox in the EditItemTemplate.
    >
    > That all seems to work; so far so good and the page looks good.
    >
    > Now comes the rub.
    >
    > I want to be able to format the text with carrage returns.
    >
    > The Label control wants these to be rendered as <br />; but the textBox
    > wants these rendered as CRLF.
    >
    > I find there is a OnPreRender even that looks like I could replace the crlfs
    > with the proper new line sequence for the respective control.
    >
    > Problem is, how do I refernce the Label and Textbox fields burried in the
    > templates in the DesignView from the PreRender event?
    >
    > In desperation I tried using the textbox in the ItemTamplate and that works,
    > but the page looks a little funny having labels for all for the other fields
    > and a textbox for this one.
    >
    > Gary


    The label control is read-only so you can do what you like with the
    text read from the database during the binding process. Have you tried
    anything like this?

    I'm not sure how to do this in VB but I have tried this in C# and it
    seems to work:

    <asp:label ID="labNotes" runat="server"
    Text='<%# Eval("Notes").ToString().Replace("\n","<br />") %>'></
    asp:label>

    where the label is in the ItemTemplate and the column named "Notes"
    contains line delimited text.

    HTH
     
    Stan, Jun 13, 2008
    #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. mutant
    Replies:
    0
    Views:
    448
    mutant
    Nov 27, 2005
  2. Michael B. Trausch

    Attempting to parse free-form ANSI text.

    Michael B. Trausch, Oct 22, 2006, in forum: Python
    Replies:
    11
    Views:
    523
    Frederic Rentsch
    Oct 25, 2006
  3. Jean-Paul Calderone

    Re: Attempting to parse free-form ANSI text.

    Jean-Paul Calderone, Oct 22, 2006, in forum: Python
    Replies:
    2
    Views:
    308
    Michael B. Trausch
    Oct 24, 2006
  4. george
    Replies:
    0
    Views:
    1,164
    george
    Aug 29, 2008
  5. mohammed_a_o
    Replies:
    0
    Views:
    304
    mohammed_a_o
    Nov 30, 2010
Loading...

Share This Page