Strings for Strings Query

G

g

hi,

I intend to make a page that will display each categories under a main
category. This is done with XML. A piece of XML code as below.
<xml>
<Category name="Category1">
<Category name="Sub Category1"></Category>
<Category name="Sub Category2"></Category>
</Category>
<Category name="Category2"></Category>
<xml>
I manage to create a page that lay out all the main categories and
hyperlink them.

The problem is this , my hyperlink look like this : <a href
=category.asp?Category=Sub Category1 >

I need to make it look like this <a href
=category.asp?Category=Sub%20Category1 >

Other then SPACE have to be %20, ampersand have to be%26 so on and forth

Is there anyway to encode this: <a href =category.asp?Category=Sub
Category1 > to <a href =category.asp?Category=Sub%20Category1 >???


thank you for any help is given.
 
S

Steven Burn

Replace the spaces with the Replace function?

SomeString = Replace(SomeString, " ", "_")

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
A

Aaron Bertrand [MVP]

Your hyperlink should be:

response.write "<a href='category.asp?Category=" & server.URLEncode("Sub
Category 1") & "'>"

Also, rather than passing big bulky strings around in querystrings, consider
using a smaller primary key (like an integer)... you avoid the above
problem, you reduce overall network bandwidth, you make it less tempting for
people to guess categories by just typing whatever they want into the URL,
and you make it less imposing on users (who may have bookmarked a URL) when
you change "Sub Category 1" to "Sub Category 5"...
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top