A
ATS
HOWTO Make CStr for JavaScript on ASP w/ Request.Form and QueryString
In ASP, Request.Form and Request.QueryString 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=TEST
<%@ Language=JavaScript %>
<%
Response.AddHeader("Pragma", "No-Cache");
%>
<html>
<%
var csTST = Request.Form("STATE");
if ((csTST == "") || (typeof(csTST) == "undefined"))
{
%>
Request.Form("STATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.Form("STATE") = "<%=csTST%>"<br>
<%
}
csTST = Request.QueryString("STATE");
if ((csTST == "") || (typeof(csTST) == "undefined"))
{
%>
Request.QueryString("STATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.QueryString("STATE") = "<%=csTST%>"<br>
<%
}
%>
</html>
From this sample, the output will be as such:
Request.Form("STATE") = ""
Request.QueryString("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.QueryString 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=TEST
<%@ Language=JavaScript %>
<%
Response.AddHeader("Pragma", "No-Cache");
%>
<html>
<%
var csTST = Request.Form("STATE");
if ((csTST == "") || (typeof(csTST) == "undefined"))
{
%>
Request.Form("STATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.Form("STATE") = "<%=csTST%>"<br>
<%
}
csTST = Request.QueryString("STATE");
if ((csTST == "") || (typeof(csTST) == "undefined"))
{
%>
Request.QueryString("STATE") is NULL/Empty/Blank<br>
<%
}
else
{
%>
Request.QueryString("STATE") = "<%=csTST%>"<br>
<%
}
%>
</html>
From this sample, the output will be as such:
Request.Form("STATE") = ""
Request.QueryString("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?