Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Response Object Error - Missing default property

    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It may be in the way you're calling the code to get the calendar included in your pages.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #7
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I call the calendar in the pages using;

    <% = New gyCalendar %>

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try:

    <%= someVar = New gyCalendar %>

    Remember to Dim someVar if you're using <%Option Explicit%> (and you definitely should be using it).
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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...
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #11
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    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:
    Code:
    <% 
    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!!

    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    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.

    Last edited by whammy; 11-18-2003 at 04:00 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •