Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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
 
Old September 20th, 2004, 11:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default how do you

how do you use the replace function?

i.e I want to use it so that any <br> will be replaced with a vbcrlf?

thanks

Adam

 
Old September 20th, 2004, 11:38 AM
Authorized User
 
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Use it like so

Dim string
string = Replace(Request.Form("yourinput"), "<br>", vbCRLF)




You change the Request.Form to Request.Querystring for querystrings.

Chris
 
Old September 20th, 2004, 11:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

thanks Chris; can you see anything wrong with this?

<%=replace(rsArticle("Detail"), vbcrlf, "<br>")%>

adam

 
Old September 20th, 2004, 11:54 AM
Authorized User
 
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

What you have will replace all vbCRLF with <br> or single line breaks. If you want double spacing then do the following:

<%=replace(rsArticle("Detail"), vbcrlf, "<br><br>")%>

Also of note, what I orginally wrote actually affects stores that replace in the database.
 
Old September 20th, 2004, 07:00 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Adam H-W
The following fuction will do this and more, it's a fairly self expalnatory and VERY useful function. I run this function on every free text area form element value when inserting or updating. (Dont forget the old trim function also)

Place the following code in a functions.inc file (no need to put it on every page):

-----------cut n paste-------------
  Function StoreText(theText)
    StoreText = ""
    on error resume next
    StoreText = CStr(theText)
    if (len(StoreText) > 0) Then
      StoreText = Replace(StoreText, """", "&quot;", 1, -1, 1)
      StoreText = Replace(StoreText, "'", "''", 1, -1, 1)
      StoreText = Replace(StoreText, vbCrLf, "<BR>", 1, -1, 1)
    end if
  End Function
--------------end ------------------

Put this in the head of every page that uses the function
-----------cun n paste--------------

-----------finish-------------------

Now when inserting a value that may have a <br> or " or '
'" & trim(storeText(request.form("fieldname"))) & "'

Dont be afraid to run it on every form variable where there may possibly be one of these characters, users will do what we least expect.

Wind is your friend
Matt








Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.