HighTechTalks DotNet Forums  

datalist vbCrLf & OnEditCommand/OnUpdateCommand Event Procedures

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss datalist vbCrLf & OnEditCommand/OnUpdateCommand Event Procedures in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jim in Arizona
 
Posts: n/a

Default datalist vbCrLf & OnEditCommand/OnUpdateCommand Event Procedures - 12-29-2006 , 05:31 PM






Posted in aspnet also. Sorry but no one responded there so hoping for
some luck here .....

Is there an easier way to make a datalist aware of line breaks within
text fields?

I have a text box that users can type into. If they press the enter key
a few times, VB sees this as a vbCrLf. This text is inserted into a text
field in an SQL server. When the data is read and presented by the
datalist, the line breaks are gone. All the text is just together
without paragraphing.

I am able to keep the spaces if I try this approach:

txtNewLog.Text = Replace(txtNewLog.Text, vbCrLf, "<br />")

That works when the text is shown by the datalist. But when I go to
'edit' that text, the text shows the <br /> tags. If the user tries to
post that back, I get this error:

A potentially dangerous Request.Form value was detected from the client
(dlNotes$ctl00$txtEditLog="...m''s Test.<br /><br />A line b...").

This is an understandable security precaution on .Net's part and I don't
wish to turn of this validation.

The other option I tried was to revert things back on the 'EditItem'
procedure (the OnEditCommand="UpdateNote" within the datalist
paramaters) by reversing the replace function, like so:

txtEditLog.Text = Replace(txtEditLog.Text, "<br />", vbCrLf)

The problem with that is when I execute the Edit sub, the control
'txtEditLog' cannot be found using this code within the sub:

Sub EditNote(ByVal sender As Object, ByVal e As DataListCommandEventArgs)

Dim txtEditLog As New TextBox
txtEditLog = e.Item.FindControl("txtEditLog")

txtEditLog.Text = Replace(txtEditLog.Text, "<br />", vbCrLf)
......
End Sub

Controls can be found just fine in the Update Procedure (the
OnUpdateCommand="UpdateNote" within the datalist paramaters). I wasn't
aware until now that controls cannot be declared and found within the
OnEditCommand event procedure.

Any advice on fixing this delimma?

TIA,
Jim

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.