escaping characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    escaping characters

    I need to put the following code within a <% %> block :

    response.write "<tr>" &_
    "<td bgcolor=eeeeee> <a href=""company. asp?company=rs( "companyKey ")" &
    "orderby=name"" >"&naym&"</a></td>"


    How do I escape the characters " etc?



    *** Sent via Developersdex http://www.developersdex.com ***
  • Ray Costanzo [MVP]

    #2
    Re: escaping characters

    Well, one way would be to not response.write it, but do:

    %>
    <td bgcolor=eeeeee> <a
    href="company.a sp?company=<%=r s("companyKey") %>&orderby=name "><%=naym%> </a></td>
    %<

    Or, if you would like to keep it as is, you already have the " escaped, in
    VBScript. In VBScript, you use "" where you want ", as you have it.

    Response.Write "<tr>" & _
    "<td bgcolor=eeeeee> <a href=""company. asp?company=" & rs("companyKey" )
    & "&orderby=name" ">" & naym & "</a></td>"


    A few things to note.

    You forgot the & before "orderby=na me". That would have given a company
    value of TheCompanyKeyor derby=name

    Use spaces between your ampersands and variable names. If you don't, you'll
    play hell trying to figure out why

    <%
    Dim h1
    h1 = "john"
    Response.Write "His name is "&h1
    %>

    doesn't work.

    Ray at work



    "Mike P" <mike.parr@gmai l.com> wrote in message
    news:%23HuQNA0U GHA.6112@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    >I need to put the following code within a <% %> block :
    >
    > response.write "<tr>" &_
    > "<td bgcolor=eeeeee> <a href=""company. asp?company=rs( "companyKey ")" &
    > "orderby=name"" >"&naym&"</a></td>"
    >
    >
    > How do I escape the characters " etc?
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***[/color]


    Comment

    • Egbert Nierop \(MVP for IIS\)

      #3
      Re: escaping characters


      "Mike P" <mike.parr@gmai l.com> wrote in message
      news:%23HuQNA0U GHA.6112@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      >I need to put the following code within a <% %> block :
      >
      > response.write "<tr>" &_
      > "<td bgcolor=eeeeee> <a href=""company. asp?company=rs( "companyKey ")" &
      > "orderby=name"" >"&naym&"</a></td>"
      >
      >
      > How do I escape the characters " etc?[/color]

      Have you tried this?

      "<td bgcolor=eeeeee> <a href=""company. asp?company="
      Response.write server.htmlenco de(rs("companyK ey"))

      etc...


      Comment

      • Evertjan.

        #4
        Re: escaping characters

        Egbert Nierop (MVP for IIS) wrote on 29 mrt 2006 in
        microsoft.publi c.inetserver.as p.general:
        [color=blue]
        >
        > "Mike P" <mike.parr@gmai l.com> wrote in message
        > news:%23HuQNA0U GHA.6112@TK2MSF TNGP10.phx.gbl. ..[color=green]
        >>I need to put the following code within a <% %> block :
        >>
        >> response.write "<tr>" &_
        >> "<td bgcolor=eeeeee> <a href=""company. asp?company=rs( "companyKey ")" &
        >> "orderby=name"" >"&naym&"</a></td>"
        >>
        >>
        >> How do I escape the characters " etc?[/color]
        >
        > Have you tried this?
        >
        > "<td bgcolor=eeeeee> <a href=""company. asp?company="
        > Response.write server.htmlenco de(rs("companyK ey"))
        >
        > etc...[/color]

        Or:

        %><tr><td bgcolor='eeeeee '>
        <a href='company.a sp?company=<%=r s("companyKey") %>&orderby=name '>
        <%=naym%></a></td><%



        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Egbert Nierop \(MVP for IIS\)

          #5
          Re: escaping characters


          "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
          news:Xns9795F0E 3B125Beejj99@19 4.109.133.242.. .[color=blue]
          > Egbert Nierop (MVP for IIS) wrote on 29 mrt 2006 in
          > microsoft.publi c.inetserver.as p.general:
          >[color=green]
          >>
          >> "Mike P" <mike.parr@gmai l.com> wrote in message
          >> news:%23HuQNA0U GHA.6112@TK2MSF TNGP10.phx.gbl. ..[color=darkred]
          >>>I need to put the following code within a <% %> block :
          >>>
          >>> response.write "<tr>" &_
          >>> "<td bgcolor=eeeeee> <a href=""company. asp?company=rs( "companyKey ")" &
          >>> "orderby=name"" >"&naym&"</a></td>"
          >>>
          >>>
          >>> How do I escape the characters " etc?[/color]
          >>
          >> Have you tried this?
          >>
          >> "<td bgcolor=eeeeee> <a href=""company. asp?company="
          >> Response.write server.htmlenco de(rs("companyK ey"))
          >>
          >> etc...[/color]
          >
          > Or:
          >
          > %><tr><td bgcolor='eeeeee '>
          > <a href='company.a sp?company=<%=r s("companyKey") %>&orderby=name '>
          > <%=naym%></a></td><%[/color]

          Sorry Evertjan, this does not escape characters!

          Open for instance localstart.asp (at your default wwwroot on XP) and modify
          this paragraph

          <ul class="clsEntry Text">
          <li>Set up a personal Web server<%="&"">< "%><% response.write
          "&""><"%>
          <li>Share information within your team
          <li>Access databases
          <li>Develop an enterprise intranet
          <li>Develop applications for the Web.
          </ul>

          As you open the output with notepad, no encoding has been performed!
          However, if you use <li>Set up a personal Web server<%=
          Server.HtmlEnco de("&""><")%>< % Response.Write Server.HtmlEnco de("&""><") %>
          The output of the line with 'illegal HTML chars' is now as this
          <li>Set up a personal Web server&amp;&quo t;&gt;&lt;&amp; &quot;&gt;&l t;

          The output is fixed. At least, that is how I understood the question of the
          O.P.

          Comment

          • Evertjan.

            #6
            Re: escaping characters

            Egbert Nierop (MVP for IIS) wrote on 30 mrt 2006 in
            microsoft.publi c.inetserver.as p.general:
            [color=blue][color=green]
            >> %><tr><td bgcolor='eeeeee '>
            >> <a href='company.a sp?company=<%=r s("companyKey") %>&orderby=name '>
            >> <%=naym%></a></td><%[/color]
            >
            > Sorry Evertjan, this does not escape characters!
            >[/color]

            Right!

            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress)

            Comment

            Working...