Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem with free form text

Reply
Thread Tools

Problem with free form text

 
 
Gary Wardell
Guest
Posts: n/a
 
      06-12-2008
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


 
Reply With Quote
 
 
 
 
Stan
Guest
Posts: n/a
 
      06-13-2008
On 12 Jun, 19:39, "Gary Wardell" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve form field value if form is EncType=multipart/form-dataForm? Li Zhang ASP .Net 4 02-27-2009 01:23 AM
<form>...</form> - how to supress blank space after </form> in IE? rob c Javascript 4 12-30-2005 06:10 PM



Advertisments