Link to home
Start Free TrialLog in
Avatar of decae2001
decae2001

asked on

are there functions like escape/unescape in ASP ?

In javascript, there are two function call escape and unescape. Can I use them in ASP ?
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Yeah, its called Server.URLEncode() and Server.HTMLEncode()
Avatar of thunderchicken
thunderchicken

javascript is client based and ASP is executed on the server..

you might want to make a new function that does that before you want to encode your string.  For example:

<%
mystring = "Jim Bob; Shelia, too"
mystring = replace(replace(replace(mystring," ",""),";",""),",","")
response.write "New string is: " & mystring
%>
Avatar of decae2001

ASKER

What if I don't want to encode a URL, but to encode a
string, can I still use Server.URLEncode() and Server.HTMLEncode() ?
It does the same thing, it doesn't have to be a specific URL to do.

I would use MGFranz's suggestion over mine because it covers more.
ASKER CERTIFIED SOLUTION
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In addition, you can use escape and unescape on the server if you use JavaScript server-side code.

To use javascript or another scripting language on the server, there are two ways to code it.  If you want the default scripting language (between <% %> tags) to change, use <%@Language="JScript"%> as the first line of your asp page.

If you want to add just some javascript code on the server, use <SCRIPT Language="JScript" RUNAT="server"> </SCRIPT> tags in your code.

You can use PerlScript and other available scripting languages in a similar fashion.