...

View Full Version : Response Object Error - Missing default property



r0ck1t
11-11-2003, 09:08 AM
The code below is a class I got from asp101 and changed a little, colors, decapitalised all the html code etc. but now when I run it, all the Response.Write's are written to the browser and at the end of the class it generates the following error:

Response object error 'ASP 0185 : 80020003'

Missing Default Property

/gallery_show.asp, line 0

A default property was not found for the object.

Here is the code.

Class gyCalendar
Dim SelectedDate

Private tmpDate

Private Sub Class_Initialize()
Call ASP101Calendar()
End Sub

Public Property Get SelectedtmDate()
SelectedtmDate = FormatDateTime(tmpDate, 1)
End Property

Private Property Let SelectedtmDate(byVal dtmDate)
tmpDate = dtmDate
End Property

Private Function GetDaysInMonth(iMonth, iYear)
Select Case iMonth
Case 1, 3, 5, 7, 8, 10, 12
GetDaysInMonth = 31
Case 4, 6, 9, 11
GetDaysInMonth = 30
Case 2
If IsDate("February 29, " & iYear) Then
GetDaysInMonth = 29
Else
GetDaysInMonth = 28
End If
End Select
End Function

Private Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp

dTemp = DateAdd("d", _
-(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function

Private Function SubtractOneMonth(dtmDate)
SubtractOneMonth = DateAdd("m", -1, dtmDate)
End Function

Private Function AddOneMonth(dtmDate)
AddOneMonth = DateAdd("m", 1, dtmDate)
End Function

Private Function ASP101Calendar()
Dim dtmDate ' Date we're displaying calendar for
Dim intDIM ' Days In Month
Dim intDOW ' Day Of Week that month starts on
Dim intCurrent ' Variable we use to hold current day of month as we write table
Dim intPosition ' Variable we use to hold current position in table
'my new variables
Dim intMyNewDate ' holds new xx/xx/xx date format from the query string if we use the form
Dim intNewFullDate ' str that holds entire old date query string
Dim intFinalNewDate ' proper date format for each day link on the calendar

If IsDate(Request.QueryString("Date")) Then
dtmDate = CDate(Request.QueryString("Date"))
Else
intMyNewDate = Request.QueryString("Month") & "/" & _
Request.QueryString("Day") & "/" & _
Request.QueryString("Year")
If IsDate(intMyNewDate) Then
dtmDate = CDate(intMyNewDate)
Else
dtmDate = Date()
End If
End If
SelectedDate = dtmDate

intDIM = GetDaysInMonth(Month(dtmDate), Year(dtmDate))
intDOW = GetWeekdayMonthStartsOn(dtmDate)

Response.Write("<table class=""table""><tr><td><table class=""contenttable"">")
Response.Write("<tr class=""headertr""><td>calendar</td></tr><tr><td>")
Response.Write("<table><tr><td bgcolor=""#60786B"" align=""center"" colspan=7>")
Response.Write("<table width=""100%"" border=0 cellspacing=0 cellpadding=0><tr>")
Response.Write("<td align=""right""><a class=""smLink"" href=""" & Request.ServerVariables("SCRIPT_NAME") & "?Date=" & SubtractOneMonth(dtmDate) & """>&lt;&lt;</font></a></td>")
Response.Write("<td align=""center""><span class=""lgText"">" & MonthName(Month(dtmDate)) & " " & Year(dtmDate) & "</span></td>")
Response.Write("<td align=""left""><a class=""smLink"" href=""" & Request.ServerVariables("SCRIPT_NAME") & "?Date=" & AddOneMonth(dtmDate) & """>&gt;&gt;</a></td>")
Response.Write("</tr></table></td></tr><tr>")
Response.Write("<td align=""center"" bgcolor=""#999999""><b>Sun</b><br><img src=""./images/spacer.gif"" width=""30"" height=""1"" border=""0""></td>")
Response.Write("<td align=""center"" bgcolor=""#999999""><b>Mon</b><br><img src=""./images/spacer.gif"" width=""30"" height=""1"" border=""0""></td>")
Response.Write("<td align=""center"" bgcolor=""#999999""><b>Tue</b><br><img src=""./images/spacer.gif"" width=""30"" height=""1"" border=""0""></td>")
Response.Write("<td align=""center"" bgcolor=""#999999""><b>Wed</b><br><img src=""./images/spacer.gif"" width=""30"" height=""1"" border=""0""></td>")
Response.Write("<td align=""center"" bgcolor=""#999999""><b>Thu</b><br><img src=""./images/spacer.gif"" width=""30"" height=""1"" border=""0""></td>")
Response.Write("<td align=""center"" bgcolor=""#999999""><b>Fri</b><br><img src=""./images/spacer.gif"" width=""30"" height=""1"" border=""0""></td>")
Response.Write("<td align=""center"" bgcolor=""#999999""><b>Sat</b><br><img src=""./images/spacer.gif"" width=""30"" height=""1"" border=""0""></td>")

If intDOW <> 1 Then
Response.Write("<tr bgcolor=""#EEEEEE"">")
intPosition = 1
Do While intPosition < intDOW
Response.Write("<td bgcolor=""#EEEEEE"">&nbsp;</td>")
intPosition = intPosition + 1
Loop
End If

intCurrent = 1
intPosition = intDOW
Do While intCurrent <= intDIM

If intPosition = 1 Then
Response.Write("<tr>")
End If

If intCurrent = Day(dtmDate) Then
Response.Write("<td bgcolor=""#555555""><b>" & intCurrent & "</b><br><br></td>")
Else
intNewFullDate = CStr(Month(dtmDate) & "/" & intCurrent & "/" & Year(dtmDate))
intFinalNewDate = FormatDateTime(intNewFullDate, 2)
Response.Write("<td bgcolor=""#EEEEEE""><a href=""http://www.gympieyouth.com/events_view.asp?Date=" & intFinalNewDate & """>" & intCurrent & "</a><br><br></td>")
End If

If intPosition = 7 Then
Response.Write("</tr>")
intPosition = 0
End If

intCurrent = intCurrent + 1
intPosition = intPosition + 1
Loop

If intPosition <> 1 Then
Do While intPosition <= 7
Response.Write("<td bgcolor=""#EEEEEE"">&nbsp;</td>")
intPosition = intPosition + 1
Loop
End If
Response.Write("</tr>")
Response.Write("</table>")

End Function
End Class

You can see the error for yourself at http://www.gympieyouth.com

Roy Sinclair
11-11-2003, 02:37 PM
You seem to be calling a Function named ASP101Calendar but since it doesn't return a value, it should be a Sub not a Function.

r0ck1t
11-12-2003, 12:13 AM
I have changed it to

Private Sub ASP101Calendar()

*rest of code*

End Sub

and it gives the same error, is there more I have to change? I haven't really used Subs, so I have no idea!

Roy Sinclair
11-12-2003, 02:47 PM
Actually, when looking at the html it appears the whole class executed and was finished. The problem doesn't appear to be in the code you've posted.

r0ck1t
11-13-2003, 12:00 AM
Hmm, well the error appears only on the pages that I have the calendar displayed on, although it is included in every page it isn't used on all of them yet.

I will have a little play around with it, see what I can come up with.

Thanks for the help,

Luke

Roy Sinclair
11-13-2003, 07:05 PM
It may be in the way you're calling the code to get the calendar included in your pages.

r0ck1t
11-13-2003, 08:03 PM
I call the calendar in the pages using;

<% = New gyCalendar %>

Roy Sinclair
11-13-2003, 08:22 PM
Try:

<%= someVar = New gyCalendar %>

Remember to Dim someVar if you're using <%Option Explicit%> (and you definitely should be using it).

glenngv
11-14-2003, 12:28 PM
Originally posted by Roy Sinclair
Try:

<%= someVar = New gyCalendar %>

Remember to Dim someVar if you're using <%Option Explicit%> (and you definitely should be using it).

Extra equal sign...

Roy Sinclair
11-14-2003, 04:21 PM
Originally posted by glenngv
Extra equal sign...

Not sure it'll work without that "extra" equal sign. Probably shoud have written it as:

<%
someVar = New gyCalendar
response.write someVar
%>

That would have made it clear.

M@rco
11-15-2003, 01:33 PM
Originally posted by Roy Sinclair
Not sure it'll work without that "extra" equal sign. Probably shoud have written it as:

<%
someVar = New gyCalendar
response.write someVar
%>

That would have made it clear. Two things:

1) You can't create an object like that - you need to use the Set keyword:
<%
Set someVar = New gyCalendar
response.write someVar
%>

2) Since someVar is an instance of the gyCalendar class, the line "response.write someVar" will only work if the class exposes a default property. If not, then you'll get the precise error that started this thread off!!

;)

whammy
11-18-2003, 02:44 AM
In addition to what Marcus said, that will just create a boolean value which is pretty frustrating to debug. I know, I've done it a few times on accident, just like noted above:

<% = somevar = somethingelse %>

Usually what happens in that case is you get "True" or "False" written to the browser. Then you're like "What the heck?!?". Not to mention the same thing can happen if you do something strange to a variant somewhere else, and then try to use it later. For instance, I once concatenated a string, and then used the & _ in some lines in addition to other concatenation (trying to get it done quick, copy and paste) - with the same results:



False


What's worse is I wasn't writing the results to the browser, I was trying to use them as a variable in part of the application where a boolean value wasn't an option.

Those are the worst typos to debug in ASP, I think (especially since you have to put response.write statements everywhere to "step through" the logic)... but you definitely learn from them.

:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum