|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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 *** 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 *** "Mike P" <mike.p***@gmail.com> wrote in message Have you tried this?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? "<td bgcolor=eeeeee><a href=""company.asp?company=" Response.write server.htmlencode(rs("companyKey")) etc... Egbert Nierop (MVP for IIS) wrote on 29 mrt 2006 in
microsoft.public.inetserver.asp.general: Show quote > Or:> "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... %><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)
Show quote
"Evertjan." <exjxw.hannivo***@interxnl.net> wrote in message Sorry Evertjan, this does not escape characters!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><% 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&"><&">< The output is fixed. At least, that is how I understood the question of the O.P. Egbert Nierop (MVP for IIS) wrote on 30 mrt 2006 in
microsoft.public.inetserver.asp.general: >> %><tr><td bgcolor='eeeeee'> Right!>> <a href='company.asp?company=<%=rs("companyKey")%>&orderby=name'> >> <%=naym%></a></td><% > > Sorry Evertjan, this does not escape characters! > -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress) |
|||||||||||||||||||||||