Spaces

M

Mark Sippitt

I have a problem with the following code :

Response.write rstContacts(1).Value

The above line prints "Andark Marine"

However the following only passes "Andark" and stops at
the space. How do I get over this ? Its the same with all
records.

Response.Write("<td align=center><a
ref=companycontacts.asp?Company=" & rstContacts(1).Value
& " target=_new><img src=images\contact.ico width=25
height=25 border=0></a></td>")

Thanks for our help
Mark
 
S

Shailesh Humbad

Two things:
1. Use Chr(34) to put quotes around the href.
2. Use Server.UrlEncode to encode the link.

like this:

Response.Write("<td align=center><a
href="&Chr(34)&"companycontacts.asp?Company=" &
Server.UrlEncode(rstContacts(1).Value)&Chr(34)&
& " target=_new><img src=images\contact.ico width=25
height=25 border=0></a></td>")

If rst may contain nulls, then put urlencode into a function like this:

Function PrintEncoded(strValue)
If IsNull(strValue) Then
PrintEncoded = ""
Else
PrintEncoded = Server.UrlEncode(strValue)
End If
End Function

UrlEncode will give an error if it is given a null value.

Shailesh.
 
M

Mats

Generally yo can't have spaces in a Querystring, parsing stops at the
space.(I've seen somewhere that Apache might tolerate it)
Mats
 
V

vivek

why use response.write to display a link which has zillion double quotes, to
put it in a more simple way do this:

end you asp tag
%>

height=25 border=0></a></td>

<%
then restart your asp code here
%>

Vivek
 
T

Tom B

Response.Write "<td align=""center"">" & _
"<a href=""companycontacts.asp?Company=" & _
rstContacts(1).Value & _
""" target=_new>" & _
"<img src=""images\contact.ico"" width=""25""
height=""25"" border=""0""></a></td>"

All I've done is add double quotes around the properties of your tags. The
result will be
<td align="center"><a href="companycontacts.asp?Company=Andark Marine"><img
src="images\contact.ico" width="25" height="25" border="0"></a></td>

I've never tried but I'm pretty sure an ico file isn't going to show up on
IE
 
M

Mark Sippitt

Vivek,

I think you will find that method also does not work unfortunately, but
agree with you about the clarity, without the complication of double
quotes...

Mark Sippitt MIAP
Senior Developer
 
M

Mark Schupp

The parameter value should also be urlencoded

Response.Write "<td align=""center"">" & _
"<a href=""companycontacts.asp?Company=" & _
Server.URLEncode(rstContacts(1).Value) & _
""" target=_new>" & _
"<img src=""images\contact.ico"" width=""25""
height=""25"" border=""0""></a></td>"


--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
(e-mail address removed)
http://www.ielearning.com
714.637.9480 x17
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top