Solved

are there functions like escape/unescape in ASP ?

Posted on 2001-07-13
6
3,759 Views
Last Modified: 2008-03-10
In javascript, there are two function call escape and unescape. Can I use them in ASP ?
0
Comment
Question by:decae2001
6 Comments
 
LVL 18

Expert Comment

by:mgfranz
ID: 6281494
Yeah, its called Server.URLEncode() and Server.HTMLEncode()
0
 
LVL 11

Expert Comment

by:thunderchicken
ID: 6281495
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
%>
0
 

Author Comment

by:decae2001
ID: 6281536
What if I don't want to encode a URL, but to encode a
string, can I still use Server.URLEncode() and Server.HTMLEncode() ?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 11

Expert Comment

by:thunderchicken
ID: 6281552
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.
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 15 total points
ID: 6281677
You can do this with any string;

Server.URLEncode(String)

The URLEncode method takes a string and converts it into a URL-encoded format. For example, you can use URLEncode to ensure that hyperlinks in your Active Server Pages are in the correct format.

There is one mandatory argument.

String

The String argument is the string to be encoded.

Code:
<% theStr = Server.URLEncode("This is a test of the URLEcode() Function, % & * # ;")
Response.Write theStr
%>

Output:
This+is+a+test+of+the+URLEcode%28%29+Function%2C+%25+%26+%2A+%23+%3B
0
 
LVL 5

Expert Comment

by:dgorin
ID: 6282657
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.

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now