[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4292
  • Last Modified:

are there functions like escape/unescape in ASP ?

In javascript, there are two function call escape and unescape. Can I use them in ASP ?
0
decae2001
Asked:
decae2001
1 Solution
 
mgfranzCommented:
Yeah, its called Server.URLEncode() and Server.HTMLEncode()
0
 
thunderchickenCommented:
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
 
decae2001Author Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
thunderchickenCommented:
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
 
mgfranzCommented:
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
 
dgorinCommented:
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now