Solved

are there functions like escape/unescape in ASP ?

Posted on 2001-07-13
6
3,801 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

16 Experts available now in Live!

Get 1:1 Help Now