how to use decodeURIComponent in asp?
From my javascript i try to post data to my asp page using encodeURIComponent
var dd = encodeURIComponent(document.getElementById("Remarks").innerHTML);
How i decode my encodeURIComponent in asp page using vbscript?
hoping your support
Solution 1:
i think you mean you want to decode the URI component in the vb.net code behind and not vb script.
the thing here is you don't have to it...Request.Querystring("query_string_variable")
automatically does it for you.
if you explicitly want to do it you can use
HttpUtility.UrlDecode()
in .net
if you want to do it in VBscript , see the answer by Valerio
Solution 2:
I guess you need this: Classic ASP URLDecoder function using decodeURIComponent
<%
FUNCTION URLDecoder(str)
'// This function:
'// - decodes any utf-8 encoded characters into unicode characters eg. (%C3%A5 = å)
'// - replaces any plus sign separators with a space character
'//
'// IMPORTANT:
'// Your webpage must use the UTF-8 character set. Easiest method is to use this META tag:
'// <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
'//
Dim objScript
Set objScript = Server.CreateObject("ScriptControl")
objScript.Language = "JavaScript"
URLDecoder = objScript.Eval("decodeURIComponent(""" & str & """.replace(/\+/g,"" ""))")
Set objScript = NOTHING
END FUNCTION
%>