Help - Can someone please tell me what I'm doing wrong here?

W

What-a-Tool

I'm going out out of my mind trying to get this to work with no luck. The
error message I get is at the bottom. Can someone please tell me what I'm
doing wrong here. I've tried this a million different ways and can't get it
to work. I can get it to work with VBScript, but I need to do this project
in JavaScript. HELP- PLEASE!?

<%@Language=JavaScript%>
<%Response.buffer=true%>

<%
if(Request.Form("txtusername") == "" || (Request.Form("txtpassword") == ""))
{
%>

<HTML>
<HEAD>
<meta http-equiv="Content-Language" content="en-us">
<title>Error Information</title>
</HEAD>
<BODY>

<Some HTML text Here>


<%
}
else
{

ExpireDate = new Date();
ExpireDate.setYear = (ExpireDate.getYear() + 1);

Response.Cookies("User").expires = ExpireDate.toLocaleString();

Response.Cookies("User")("UName") = Request.Form("txtusername");
Response.Cookies("User")("Pword") = Request.Form("txtpassword");

Response.Redirect("chapt8default2.asp")

Response.End

}
%>

Microsoft JScript runtime error '800a01b6'

Object doesn't support this property or method

/aspchapt8/auth.asp, line 47 (this is line
47 -Response.Cookies("User").expires = ExpireDate.toLocaleString();
-)

----------------------------------------------------------------------------
-
Thanks in Advance for any help given

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
A

Aaron [SQL Server MVP]

Have you tried using a standard date instead of a proprietary getLocale()
date? This worked fine for me:

<script language=jscript runat=server>

var ed = new Date();
var dStr = getISOdate(ed);

Response.Write(dStr);
Response.Cookies("User")("UName") = "blah";
Response.Cookies("User").Expires = dStr;

function getISOdate(d)
{
var dStr = d.getFullYear() + '-'
dStr += (ed.getMonth()<9) ? '0' : '';
dStr += (ed.getMonth()+1) + '-';
dStr += (ed.getDate()<10) ? '0' : '';
dStr += (ed.getDate());
return dStr;
}

</script>
 
B

Bob Barrows [MVP]

What-a-Tool said:
I'm going out out of my mind trying to get this to work with no luck.
The error message I get is at the bottom. Can someone please tell me
what I'm doing wrong here. I've tried this a million different ways
and can't get it to work. I can get it to work with VBScript, but I
need to do this project in JavaScript. HELP- PLEASE!?
Microsoft JScript runtime error '800a01b6'

Object doesn't support this property or method

/aspchapt8/auth.asp, line 47 (this is line
47 -Response.Cookies("User").expires = ExpireDate.toLocaleString();
-)

JScript, as opposed to VBScript, is case-sensitive. You are going to need
keep a link to the online documentation handy so you can verify which
letters need to be capitalized. This is the starting point:
http://msdn.microsoft.com/library/en-us/iissdk/iis/iis_web_pages.asp

Let's look at the line causing the error:
Response.Cookies("User").expires = ExpireDate.toLocaleString();
Follow the Built-in Objects link get to the page from which you can follow
the Response Object link to finally reach here:
http://msdn.microsoft.com/library/en-us/iissdk/iis/ref_vbom_resoccook.asp

You will see that "expires" needs to be "Expires"

HTH,
Bob Barrows
 
A

Aaron [SQL Server MVP]

You will see that "expires" needs to be "Expires"

I meant to note that it was the first piece of the code that I changed, but
on my machine at least, expires and Expires seemed to perform equally well.

What fixed the problem for me (though I was getting Type Mismatch) was using
a sensible date format.
 
W

What-a-Tool

HELP- PLEASE!?
Microsoft JScript runtime error '800a01b6'

Object doesn't support this property or method

/aspchapt8/auth.asp, line 47 (this is line
47 -Response.Cookies("User").expires = ExpireDate.toLocaleString();
-)

Just want to say thanks.
I got it working by re-formatting my date string as suggested, and now it
works as advertised by my text book.
Thanks for taking the time!

Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top