|
 |
asp_database_setup thread: Replace a blank space
Message #1 by Eli Schilling <eschilli@t...> on Wed, 25 Jul 2001 10:06:39 -0700
|
|
I have a database that contains a persons first and last name in the same
field. After a search is run all similar names are displayed with a
hyperlink to that persons info.
They hyperlink looks like this:
<a href="info.asp?strName=<% request("strName") %>">Click to view the
persons info</a>
However, it only links to the persons first name because of the space
between the first and last name. How can I modify the variable before it
gets to the HREF so that instead of a blank space there is a %20. What I
run into is the user sees:
John Doe
John Smith
John Thompson
No matter which link they click it takes them to John Doe's info because
alphabetically, he is first.
Thanks in advance,
Eli
Message #2 by "Craig Flannigan" <ckf@k...> on Thu, 26 Jul 2001 08:11:54 +0100
|
|
I might be wrong, but do you not need and equals sign (=) in front of your
Request?
Such as...
<a href="info.asp?strName=<% =request("strName") %>">Click to view the
persons info</a>
Other than that, I use nearly the same code above, and have 3 words, all
with spaces and it works fine.
-----Original Message-----
From: Eli Schilling [mailto:eschilli@t...]
Sent: Wednesday 25 July 2001 18:07
To: ASP Database Setup
Subject: [asp_database_setup] Replace a blank space
I have a database that contains a persons first and last name in the same
field. After a search is run all similar names are displayed with a
hyperlink to that persons info.
They hyperlink looks like this:
<a href="info.asp?strName=<% request("strName") %>">Click to view the
persons info</a>
However, it only links to the persons first name because of the space
between the first and last name. How can I modify the variable before it
gets to the HREF so that instead of a blank space there is a %20. What I
run into is the user sees:
John Doe
John Smith
John Thompson
No matter which link they click it takes them to John Doe's info because
alphabetically, he is first.
Thanks in advance,
Eli
Message #3 by "Ken Schaefer" <ken@a...> on Thu, 26 Jul 2001 22:51:42 +1000
|
|
You can not have spaces in URLs. Spaces need to be escaped with % + their
ASCII equivalent (%20)
The reason why your links work for you, if probably because you are using
IE. When IE runs into a link that has a space, it automatically encodes the
GET request for you when you click on the link. If you tried the same thing
in Netscape Navigator, the link wont work... (or the request will be for a
file only upt ot the point where the space is:
http://www.myserver.com/default.asp?var=something with spaces in it
(your email proggie will probably stop underlining at the first space).
Use Server.URLEncode() on the values of any params you need to pass to
escape illegal characters.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "Craig Flannigan" <ckf@k...>
To: "ASP Database Setup" <asp_database_setup@p...>
Sent: Thursday, July 26, 2001 5:11 PM
Subject: [asp_database_setup] RE: Replace a blank space
: I might be wrong, but do you not need and equals sign (=) in front of your
: Request?
:
: Such as...
: <a href="info.asp?strName=<% =request("strName") %>">Click to view the
: persons info</a>
:
: Other than that, I use nearly the same code above, and have 3 words, all
: with spaces and it works fine.
:
:
:
:
: -----Original Message-----
: From: Eli Schilling [mailto:eschilli@t...]
: Sent: Wednesday 25 July 2001 18:07
: To: ASP Database Setup
: Subject: [asp_database_setup] Replace a blank space
:
:
: I have a database that contains a persons first and last name in the same
: field. After a search is run all similar names are displayed with a
: hyperlink to that persons info.
:
: They hyperlink looks like this:
: <a href="info.asp?strName=<% request("strName") %>">Click to view the
: persons info</a>
:
: However, it only links to the persons first name because of the space
: between the first and last name. How can I modify the variable before it
: gets to the HREF so that instead of a blank space there is a %20. What I
: run into is the user sees:
:
: John Doe
: John Smith
: John Thompson
:
: No matter which link they click it takes them to John Doe's info because
: alphabetically, he is first.
:
: Thanks in advance,
: Eli
:
:
: ---
: Search the best ASP Web sites using CodeHound! http://www.codehound.com
: Now it's easy to find ASP source code on the Internet. CodeHound's free
: search engine will categorize your results and even search for ASP code
: compressed in Zip files on the Internet. Stop searching dozens of
: different sites to find what you want...try CodeHound right now!
ken@a...
$subst('Email.Unsub')
Message #4 by "Daniel Walker" <danielw@w...> on Thu, 26 Jul 2001 14:18:58
|
|
Eli, I'd suggest the Replace method:
strName = Replace (strName, Chr(20), "%20")
Daniel Walker
> :
> :
> :
> : -----Original Message-----
> : From: Eli Schilling [mailto:eschilli@t...]
> : Sent: Wednesday 25 July 2001 18:07
> : To: ASP Database Setup
> : Subject: [asp_database_setup] Replace a blank space
> :
> :
> : I have a database that contains a persons first and last name in the
same
> : field. After a search is run all similar names are displayed with a
> : hyperlink to that persons info.
> :
> : They hyperlink looks like this:
> : <a href="info.asp?strName=<% request("strName") %>">Click to view the
> : persons info</a>
> :
> : However, it only links to the persons first name because of the space
> : between the first and last name. How can I modify the variable
before it
> : gets to the HREF so that instead of a blank space there is a %20.
What I
> : run into is the user sees:
> :
> : John Doe
> : John Smith
> : John Thompson
> :
> : No matter which link they click it takes them to John Doe's info
because
> : alphabetically, he is first.
> :
> : Thanks in advance,
> : Eli
> :
Message #5 by Eli Schilling <eschilli@t...> on Thu, 26 Jul 2001 10:34:25 -0700
|
|
I tried that but it doesn't seem to be replacing the spaces.
Correction on my code
...view.asp?name=" & RS("FullName") & ">" or
...view.asp?name=" & strName & ">"
The variable is set within the page so I'm not actually doing a
request("xxx")
Thanks,
Eli
-----Original Message-----
From: Daniel Walker [mailto:danielw@w...]
Sent: Thursday, July 26, 2001 7:19 AM
To: ASP Database Setup
Subject: [asp_database_setup] RE: Replace a blank space
Eli, I'd suggest the Replace method:
strName = Replace (strName, Chr(20), "%20")
Daniel Walker
> :
> :
> :
> : -----Original Message-----
> : From: Eli Schilling [mailto:eschilli@t...]
> : Sent: Wednesday 25 July 2001 18:07
> : To: ASP Database Setup
> : Subject: [asp_database_setup] Replace a blank space
> :
> :
> : I have a database that contains a persons first and last name in the
same
> : field. After a search is run all similar names are displayed with a
> : hyperlink to that persons info.
> :
> : They hyperlink looks like this:
> : <a href="info.asp?strName=<% request("strName") %>">Click to view the
> : persons info</a>
> :
> : However, it only links to the persons first name because of the space
> : between the first and last name. How can I modify the variable
before it
> : gets to the HREF so that instead of a blank space there is a %20.
What I
> : run into is the user sees:
> :
> : John Doe
> : John Smith
> : John Thompson
> :
> : No matter which link they click it takes them to John Doe's info
because
> : alphabetically, he is first.
> :
> : Thanks in advance,
> : Eli
> :
Message #6 by "Hasenfratz, Philipp" <maillist@e...> on Thu, 26 Jul 2001 21:29:44 +0200
|
|
> I tried that but it doesn't seem to be replacing the spaces.
>
> Correction on my code
>
> ...view.asp?name=" & RS("FullName") & ">" or
> ...view.asp?name=" & strName & ">"
>
> The variable is set within the page so I'm not actually doing a
> request("xxx")
>
> Thanks,
> Eli
Just encode the output string : strName = Server.URLencode(strName) . the
same with RS("FullName") and it works (I hope)
---Philipp
Message #7 by Eli Schilling <eschilli@t...> on Thu, 26 Jul 2001 14:49:24 -0700
|
|
That worked great!!! Thank you!!!
-Eli
-----Original Message-----
From: Hasenfratz, Philipp [mailto:maillist@e...]
Sent: Thursday, July 26, 2001 12:30 PM
To: ASP Database Setup
Subject: [asp_database_setup] RE: Replace a blank space
> I tried that but it doesn't seem to be replacing the spaces.
>
> Correction on my code
>
> ...view.asp?name=" & RS("FullName") & ">" or
> ...view.asp?name=" & strName & ">"
>
> The variable is set within the page so I'm not actually doing a
> request("xxx")
>
> Thanks,
> Eli
Just encode the output string : strName = Server.URLencode(strName) . the
same with RS("FullName") and it works (I hope)
---Philipp
|
|
 |