 |
| ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 3rd, 2004, 07:48 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
CRLF retention
I have a form which includes a textarea. If I type in text, including line breaks, and then pass the form to another ASP page, the "%0D%0A" line breaks show in the form input string. But if I assign the field to a variable, the line breaks are dropped. I need to be able to convert those to "<br>" so that I can store the result in a database or text file and be able to get them back for HTML display. Is there a solution to this problem?
|
|

March 3rd, 2004, 10:17 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
<%
' ...
Dim S
S = Replace(Request("YourTextAreaString"),"%0D%0A","<B R>")
' Or maybe this...
' S = Replace(Request("YourTextAreaString"),vbCrLf,"<BR> ")
' ...
%>
|
|

March 4th, 2004, 02:09 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
I usually store the data as entered, and then if I need to show in in HTML, I do that replacement before dumping the string to HTML. This saves you having to store the <br> in the database, but more importantly, if this value is edited in the furture, it's edited from the way it was entered without automatic modification. Depending on who might be editing the data, they may not understand what <br> means.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

March 4th, 2004, 06:34 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I love the idea, but how do you make it work? The data, as entered, is visible in the address string as "%0D%0A", but it cannot be assigned anywhere. Assigning the request string to a variable results in the "%0D%0A" disappearing from the string. So how do you manage to store the string in a database including the CRLF command?
Quote:
quote:Originally posted by planoie
I usually store the data as entered, and then if I need to show in in HTML, I do that replacement before dumping the string to HTML. This saves you having to store the <br> in the database, but more importantly, if this value is edited in the furture, it's edited from the way it was entered without automatic modification. Depending on who might be editing the data, they may not understand what <br> means.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|
|

March 5th, 2004, 04:38 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
If you add a wrap="hard" attribute to the <textarea> then soft and hard line breaks are preserved. You can store the text in the database exactly as it was input. Then when you read it back from the database and display it, just enclose the text in <pre></pre> tags and it will display exactly as it was input. There is no need to do the <br> replacement. I've used this method before on an intranet site and it worked just fine.
hth
Phil
|
|

March 5th, 2004, 09:06 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
I don't think it's necessary to add the wrap attribute in the textarea, that will happen then is that you'll get line breaks where the user didn't necessary intend for them to be. Hard returns entered into the text box will get saved in the database as hard returns. When you say "Assigning the request string to a variable results in the "%0D%0A" disappearing from the string.", what do you mean? Where are you checking that variable value? If you are writing it out to the page, then it would seem that the hard return is dissappearing, but it's not. Unless you do as phil suggested and wrap it in <pre>, or replace the hard return (vbcrlf) with <br> you won't see the entered hard return. If you look at the source HTML however, you would see the hard return, even though the browser ignores it.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

March 11th, 2004, 02:40 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks to Phil for the answer. It turns out that if I store the input field directly to the database and then wrap the HTML display in PRE tags, it works perfectly. Thanks again!
|
|

March 31st, 2004, 11:10 AM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I just found the forum today and found exactly what I was looking for in this topic! Thanks everyone.
Just one (very basic) question:
Is wrap="hard" the same as wrap="physical"?
|
|

April 1st, 2004, 04:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Yes, I believe wrap="physical" is the Netscape version of IE's wrap="hard". Try it and see...then let us know.
rgds
Phil
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Stripping CRLF?? |
crabjoe |
Classic ASP Basics |
7 |
February 26th, 2008 05:58 PM |
|
 |