Previous Code Entry
Left Arrow
How to get the file name from the URL and use it to display different data
Current Code Entry
Go Back To Code List
ASP. Classic - How to create a Reusable Replace Function
Article Entry Date: April 18,2024 @ 03:39:55 / Last Updated On: April 18,2024 @ 03:57:06
How to create a [Reusable] Function in [ASP Classic]

Making a reusable function allows you to use the function anywhere within your code project.
I've been using this function for many years to help protect against [XSS injections] and have just used it in everything.

Copy the code below, copy and paste it into an empty page, and save it as Decoding.asp.
Encoding = Change the original characters.
Decoding = Change back to original characters.

To reuse this function, add an INCLUDE FILE to all pages on which you want to use the function.

The above example will
#1: replace the Parentheses with {curly brackets} and add underscores where spaces are at.
Output: Test_{This_is_a_test}
#2: replace the {curly brackets} with Parentheses and remove the underscores.
Output: Test (This is a test);

Other Articles Related to this Entry.

ASP.NET - How to create a Reusable Replace Function in VB.NET«
ASP.NET - How to create a Reusable Replace Function in C#.NET«