ASP form textbox to HTML formatting

Discussion in 'ASP General' started by Jonathan, Oct 11, 2004.

  1. Jonathan

    Jonathan Guest

    Hi,
    I have to use the nl2br function in the asp file, luckly I got this
    code from a site. What I need done is to display textbox content the
    way it was typed/pasted i.e. with paragraph breaks and color
    formatting. The code I used is below but it does not work. Can someone
    please help me out, its rather urgent and important.


    <%
    function nl2br(str)
    nl2br=replace(str,VbCrLf, "<br >")
    end function
    response.write nl2br(essay)
    %>

    but I am from PHP world I dont understand ASP, for the time being I
    have to use this function in ASP mail script that uses CDONTS to send
    email.

    in that email script the html form in sending variable to this asp
    script and then it sends a mail with the content showing all the
    variables inside the table. The code where the value of the variables
    is displayed is something like

    "<tr><td>Essay</td><td>" & essay & "</td></tr>"


    Where my variable essay is displayed between & & now I dont know where
    to put that nl2br function

    when i write & response.write nl2br(essay) & it shows error when i
    remove the & it again shows error.

    Please help me and sorry for being so dump in sorting such a simple
    thing.


    And yes the script works without the nl2br


    regards
    Jonathan
    <%
    Function Fixquotes(theString)
    Fixquotes = Replace(theString,"'","''")
    End Function
    Function sendmail( fromwho, towho, subject, body)
    Dim objNewMail
    Set objNewMail = Server.CreateObject("CDONTS.NewMail")

    objNewMail.From = fromwho
    objNewMail.To = towho
    objNewMail.Bcc = bccwho
    objNewMail.Subject = subject
    objNewMail.BodyFormat = 0
    objNewMail.MailFormat = 0
    objNewMail.Body = body

    On Error Resume Next
    objNewMail.Send
    set objNewMail = nothing
    If Err <> 0 Then
    sendmail = "ERROR"
    else
    sendmail = "SUCCESS"
    End If


    End Function

    Name=Fixquotes(trim(Request("FName")))
    age=Fixquotes(trim(Request("age")))
    Nationality=Fixquotes(trim(Request("nationality")))
    email=Fixquotes(trim(Request("email")))
    Address=Fixquotes(trim(Request("Address")))
    Phone=Fixquotes(trim(Request("phone")))
    Profession=Fixquotes(trim(Request("profession")))
    Education=Fixquotes(trim(Request("education")))
    Essay=Fixquotes(trim(Request("essay")))

    function nl2br(str)
    nl2br=replace(str,VbCrLf, "<br >")
    end function


    Subject = "Strategic Foresight Group Essay Contest"

    body = "<table border =1><tr><td>Name</td><td>"& Name & "</td></tr>"
    & _
    "<tr><td>Age</td><td>" & age & "</td></tr>" & _
    "<tr><td>Nationality</td><td>" & nationality & "</td></tr>" & _
    "<tr><td>Email</td><td>" & email & "</td></tr>" & _
    "<tr><td>Address</td><td>" & address & "</td></tr>" & _
    "<tr><td>Phone</td><td>" & Phone & "</td></tr>" & _
    "<tr><td>Profession</td><td>" & profession & "</td></tr>" & _
    "<tr><td>Education Level</td><td>" & education & "</td></tr>" & _
    "<tr><td>Essay</td><td>" & response.write nl2br(essay) &
    "</td></tr>"

    towho = ""


    Dim Status
    Status = sendmail(name, towho, subject, body)


    Response.Redirect "index.htm"
    Response.End()
    %>
     
    Jonathan, Oct 11, 2004
    #1
    1. Advertising

  2. Jonathan

    John Guest

    <%
    VbCrLf = Chr(10)&Chr(13)
    function nl2br(str)
    nl2br=replace(str,VbCrLf, "<br >")
    end function
    response.write nl2br(essay)
    > %>
     
    John, Oct 11, 2004
    #2
    1. Advertising

  3. Jonathan

    Evertjan. Guest

    John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:

    >
    > <%
    > VbCrLf = Chr(10)&Chr(13)


    You do not need to define VbCrLf, it is build in in vbscript.

    > function nl2br(str)
    > nl2br=replace(str,VbCrLf, "<br >")
    > end function
    > response.write nl2br(essay)
    >> %>

    >
    >
    >




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
     
    Evertjan., Oct 11, 2004
    #3
  4. Jonathan

    John Guest

    Is it build in in ASP? Here when not defined i have no replace. Once defined
    it works fine ???
    Maybe some files are missing on servers where VBCrLf is defined
     
    John, Oct 11, 2004
    #4
  5. Jonathan

    Jonathan Guest

    "Evertjan." <> wrote in message news:<Xns957F89271A816eejj99@194.109.133.29>...
    > John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:
    >
    > >
    > > <%
    > > VbCrLf = Chr(10)&Chr(13)

    >
    > You do not need to define VbCrLf, it is build in in vbscript.
    >
    > > function nl2br(str)
    > > nl2br=replace(str,VbCrLf, "<br >")
    > > end function
    > > response.write nl2br(essay)
    > >> %>

    > >
    > >


    Thanks for the quick response, but could you please tell me where do I
    insert this code.

    Regards,
    Jonathan J.
    > >
     
    Jonathan, Oct 12, 2004
    #5
  6. Jonathan

    Evertjan. Guest

    Jonathan wrote on 12 okt 2004 in
    microsoft.public.inetserver.asp.general:
    > "Evertjan." <> wrote in message
    > news:<Xns957F89271A816eejj99@194.109.133.29>...
    >> John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:
    >>
    >> >
    >> > <%
    >> > VbCrLf = Chr(10)&Chr(13)

    >>
    >> You do not need to define VbCrLf, it is build in in vbscript.
    >>
    >> > function nl2br(str)
    >> > nl2br=replace(str,VbCrLf, "<br >")
    >> > end function
    >> > response.write nl2br(essay)
    >> >> %>

    >
    > Thanks for the quick response, but could you please tell me where do I
    > insert this code.


    Somewhere in your ASP vbscript code, Jonathan.

    ASP is what this NG is all about.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
     
    Evertjan., Oct 12, 2004
    #6
  7. Jonathan

    Jonathan Guest

    "Evertjan." <> wrote in message news:<Xns958067BC69B25eejj99@194.109.133.29>...
    > Jonathan wrote on 12 okt 2004 in
    > microsoft.public.inetserver.asp.general:
    > > "Evertjan." <> wrote in message
    > > news:<Xns957F89271A816eejj99@194.109.133.29>...
    > >> John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:
    > >>
    > >> >
    > >> > <%
    > >> > VbCrLf = Chr(10)&Chr(13)
    > >>
    > >> You do not need to define VbCrLf, it is build in in vbscript.
    > >>
    > >> > function nl2br(str)
    > >> > nl2br=replace(str,VbCrLf, "<br >")
    > >> > end function
    > >> > response.write nl2br(essay)
    > >> >> %>

    > >
    > > Thanks for the quick response, but could you please tell me where do I
    > > insert this code.

    >
    > Somewhere in your ASP vbscript code, Jonathan.
    >
    > ASP is what this NG is all about.


    > >> > function nl2br(str)
    > >> > nl2br=replace(str,VbCrLf, "<br >")
    > >> > end function

    I can paste this function anywhere in the ASP file but where do I
    embed the value of var essay
    and should we use response.write and how do we tackle that

    thanks
     
    Jonathan, Oct 14, 2004
    #7
  8. Jonathan

    Jonathan Guest

    (Jonathan) wrote in message news:<>...
    > "Evertjan." <> wrote in message news:<Xns958067BC69B25eejj99@194.109.133.29>...
    > > Jonathan wrote on 12 okt 2004 in
    > > microsoft.public.inetserver.asp.general:
    > > > "Evertjan." <> wrote in message
    > > > news:<Xns957F89271A816eejj99@194.109.133.29>...
    > > >> John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:
    > > >>
    > > >> >
    > > >> > <%
    > > >> > VbCrLf = Chr(10)&Chr(13)
    > > >>
    > > >> You do not need to define VbCrLf, it is build in in vbscript.
    > > >>
    > > >> > function nl2br(str)
    > > >> > nl2br=replace(str,VbCrLf, "<br >")
    > > >> > end function
    > > >> > response.write nl2br(essay)
    > > >> >> %>
    > > >
    > > > Thanks for the quick response, but could you please tell me where do I
    > > > insert this code.

    > >
    > > Somewhere in your ASP vbscript code, Jonathan.
    > >
    > > ASP is what this NG is all about.

    >
    > > >> > function nl2br(str)
    > > >> > nl2br=replace(str,VbCrLf, "<br >")
    > > >> > end function

    > I can paste this function anywhere in the ASP file but where do I
    > embed the value of var essay
    > and should we use response.write and how do we tackle that
    >
    > thanks


    Hi Evertjan,

    Was waiting for your reply as I need to be able to do this urgently.

    Using the code I have posted above can you tell me where and how I
    should insert the piece of code that you sent me.

    Thanks
     
    Jonathan, Oct 15, 2004
    #8
  9. Jonathan

    Evertjan. Guest

    Jonathan wrote on 15 okt 2004 in microsoft.public.inetserver.asp.general:
    >> > >> > function nl2br(str)
    >> > >> > nl2br=replace(str,VbCrLf, "<br >")
    >> > >> > end function

    >> I can paste this function anywhere in the ASP file but where do I
    >> embed the value of var essay
    >> and should we use response.write and how do we tackle that

    >
    > Hi Evertjan,
    >
    > Was waiting for your reply as I need to be able to do this urgently.
    >
    > Using the code I have posted above can you tell me where and how I
    > should insert the piece of code that you sent me.


    It was not my code, only commented on the VbCrLf.

    Sorry, I am afraid you don't know enough of programming to tackle this by
    yourself. Either learn more or hire a programmer.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
     
    Evertjan., Oct 15, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hazzard
    Replies:
    2
    Views:
    586
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
  2. Natty Gur
    Replies:
    0
    Views:
    496
    Natty Gur
    Jul 22, 2003
  3. =?Utf-8?B?Q2hyaXM=?=
    Replies:
    3
    Views:
    13,921
    Peter Blum
    Mar 30, 2005
  4. Jay

    Rich TextBox / HTML TextBox

    Jay, Apr 28, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    15,754
    Steve C. Orr [MVP, MCSD]
    Apr 29, 2005
  5. Jay

    Rich TextBox / HTML TextBox

    Jay, Apr 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    601
    =?Utf-8?B?TG9yZW5j?=
    Apr 28, 2005
Loading...

Share This Page