473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 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?

TIA,
Jim
Dec 28 '06 #1
0 1422

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

Similar topics

2
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...
3
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"...
0
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....
10
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...
4
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...
1
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...
1
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...
2
tjc0ol
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...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.