Home All Groups Group Topic Archive Search About


Author
29 Mar 2006 2:49 PM
Mike P
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 ***

Author
29 Mar 2006 3:15 PM
Ray Costanzo [MVP]
Well, one way would be to not response.write it, but do:

%>
<td bgcolor=eeeeee><a
href="company.asp?company=<%=rs("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=name".  That would have given a company
value of TheCompanyKeyorderby=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



Show quote
"Mike P" <mike.p***@gmail.com> wrote in message
news:%23HuQNA0UGHA.6112@TK2MSFTNGP10.phx.gbl...
>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 ***
Author
29 Mar 2006 8:57 PM
Egbert Nierop (MVP for IIS)
"Mike P" <mike.p***@gmail.com> wrote in message
news:%23HuQNA0UGHA.6112@TK2MSFTNGP10.phx.gbl...
>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?

Have you tried this?

"<td bgcolor=eeeeee><a href=""company.asp?company="
Response.write server.htmlencode(rs("companyKey"))

etc...
Author
29 Mar 2006 9:40 PM
Evertjan.
Egbert Nierop (MVP for IIS) wrote on 29 mrt 2006 in
microsoft.public.inetserver.asp.general:

Show quote
>
> "Mike P" <mike.p***@gmail.com> wrote in message
> news:%23HuQNA0UGHA.6112@TK2MSFTNGP10.phx.gbl...
>>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?
>
> Have you tried this?
>
>  "<td bgcolor=eeeeee><a href=""company.asp?company="
> Response.write server.htmlencode(rs("companyKey"))
>
> etc...

Or:

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



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Author
30 Mar 2006 7:49 AM
Egbert Nierop (MVP for IIS)
Show quote
"Evertjan." <exjxw.hannivo***@interxnl.net> wrote in message
news:Xns9795F0E3B125Beejj99@194.109.133.242...
> Egbert Nierop (MVP for IIS) wrote on 29 mrt 2006 in
> microsoft.public.inetserver.asp.general:
>
>>
>> "Mike P" <mike.p***@gmail.com> wrote in message
>> news:%23HuQNA0UGHA.6112@TK2MSFTNGP10.phx.gbl...
>>>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?
>>
>> Have you tried this?
>>
>>  "<td bgcolor=eeeeee><a href=""company.asp?company="
>> Response.write server.htmlencode(rs("companyKey"))
>>
>> etc...
>
> Or:
>
> %><tr><td bgcolor='eeeeee'>
> <a href='company.asp?company=<%=rs("companyKey")%>&orderby=name'>
> <%=naym%></a></td><%

Sorry Evertjan, this does not escape characters!

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

    <ul class="clsEntryText">
      <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.HtmlEncode("&""><")%><% Response.Write Server.HtmlEncode("&""><")  %>
The output of the line with 'illegal HTML chars' is now as this
    <li>Set up a personal Web server&amp;&quot;&gt;&lt;&amp;&quot;&gt;&lt;

The output is fixed. At least, that is how I understood the question of the
O.P.
Author
30 Mar 2006 12:03 PM
Evertjan.
Egbert Nierop (MVP for IIS) wrote on 30 mrt 2006 in
microsoft.public.inetserver.asp.general:

>> %><tr><td bgcolor='eeeeee'>
>> <a href='company.asp?company=<%=rs("companyKey")%>&orderby=name'>
>> <%=naym%></a></td><%
>
> Sorry Evertjan, this does not escape characters!
>

Right!

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

AddThis Social Bookmark Button