472,954 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

datalist vbCrLf & OnEditCommand/OnUpdateCommand Event Procedures

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?

Dec 28 '06 #1
0 1401

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
by: Dude | last post by:
Below is the code - it is finding the control, and there is no error, just not assigning the text to the label <asp:DataList id="dlGoals" runat="server" onEditCommand="myListEditHandler"...
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
by: tshad | last post by:
I have a DataList that I have set up to allow editing. The edit button does go to the subroutine defined by OnEditCommand. The problem is that it doesn't change the fields to editing fields. The...
by: Neil Jarman | last post by:
Hi, I'm new to this today, and I've got some test code (see below.) The data loads fine. I can't understand why any of the events fire. Once the page loads, clicking on thew button from the...
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist...
by: tjc0ol | last post by:
Hi guys, Im just wondering that I cannot update my database throught datagrid datalist control, and the only thing works is that I can delete, cancel, edit but when I clicked update link...
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.