HOWTO Make CStr for JavaScript on ASP w/ Request.Form and QueryString
In ASP, Request.Form and Request.QuerySt ring return objects that do not
support "toString", or any JavaScript string operation on parameters not
passed.
Example: Make a TST.asp and post to it as TST.asp?STATE=T EST
<%@ Language=JavaSc ript %>
<%
Response.AddHea der("Pragma", "No-Cache");
%>
<html>
<%
var csTST = Request.Form("S TATE");
if ((csTST == "") || (typeof(csTST) == "undefined" ))
{
%>
Request.Form("S TATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.Form("S TATE") = "<%=csTST%>"<br >
<%
}
csTST = Request.QuerySt ring("STATE");
if ((csTST == "") || (typeof(csTST) == "undefined" ))
{
%>
Request.QuerySt ring("STATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.QuerySt ring("STATE") = "<%=csTST%>"<br >
<%
}
%>
</html>
From this sample, the output will be as such:
Request.Form("S TATE") = ""
Request.QuerySt ring("STATE") = "REGISTER"
This is WRONG. The Request.Form is blank, but yet, the test for "" and even
typeof failed to detect it. What I want is some kind of CStr function so that
the returned data is 100% turned into a string that JavaScript can work upon.
Any ideas?
In ASP, Request.Form and Request.QuerySt ring return objects that do not
support "toString", or any JavaScript string operation on parameters not
passed.
Example: Make a TST.asp and post to it as TST.asp?STATE=T EST
<%@ Language=JavaSc ript %>
<%
Response.AddHea der("Pragma", "No-Cache");
%>
<html>
<%
var csTST = Request.Form("S TATE");
if ((csTST == "") || (typeof(csTST) == "undefined" ))
{
%>
Request.Form("S TATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.Form("S TATE") = "<%=csTST%>"<br >
<%
}
csTST = Request.QuerySt ring("STATE");
if ((csTST == "") || (typeof(csTST) == "undefined" ))
{
%>
Request.QuerySt ring("STATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.QuerySt ring("STATE") = "<%=csTST%>"<br >
<%
}
%>
</html>
From this sample, the output will be as such:
Request.Form("S TATE") = ""
Request.QuerySt ring("STATE") = "REGISTER"
This is WRONG. The Request.Form is blank, but yet, the test for "" and even
typeof failed to detect it. What I want is some kind of CStr function so that
the returned data is 100% turned into a string that JavaScript can work upon.
Any ideas?
Comment