PDA

View Full Version : ASP Calendar control stopped working...


vikester
10-08-2009, 08:19 PM
I have an asp calendar control on a JS page that makes a SQL call for employee birthdays on a calendar. It has the previous and next month text links on the control as well, and these just stopped working in the last 6 months to a year though I have not touched the code/page. When I mouse over one of the links the call is: javascript:_doPostBack('calBirthdays','V3592') and when I click on that link I get nothing changing on the page but the Error on Page says Object expected. The only thing I can think that we did was migrate from 1.1 to 2.0, but all the other parts of the site work, and the calendar for the CURRENT month shows up fine with all the current events (birthdays). Below is the code I am using, any help would be GREATLY appreciated:

<code>
<%@ Page Language="VB" debug=true %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Dim strSearch, strCalMo, strCalDay, strCalYr, strName As String
Dim holidays(12, 31) As String
Dim dayEvents(12, 31) As String

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' strSearch = Request.Form("txtSearch")

' lnkPrevMo.text = "«"
' lnkPrevMo.navigateURL = "birthdays.aspx?mo=" & (strMo-1)
' lnkNextMo.text = "»"
' lnkNextMo.navigateURL = "birthdays.aspx?mo=" & (strMo+1)

If Not (IsPostBack) Then
Dim strConn, strMo, strDay As String
Dim Conn1, Conn2 As SqlConnection
Dim sqlString1, sqlString2 As String
Dim objSelect1, objSelect2 As SqlCommand
Dim objRS1, objRS2 As SqlDataReader

strConn = "server=10.10.2.31;UID=;pwd=;database=Employee"
Conn1 = New SqlConnection(strConn)
Conn1.Open()

sqlString1 = "SELECT * FROM Zak_Employees WHERE Birthday IS NOT NULL ORDER BY Birthday"
objSelect1 = New SqlCommand(sqlString1, Conn1)
objRS1 = objSelect1.ExecuteReader()
'objRS1.Read()

Dim intCtr1, intCtr2 As Integer
For intCtr1 = 0 To 11
For intCtr2 = 0 To 30
dayEvents(intCtr1, intCtr2) = ""
Next
Next

Do While objRS1.Read()
strMo = Month(objRS1("Birthday"))
strDay = Day(objRS1("Birthday"))
strName = "<font color='darkblue'><b>" + objRS1("FirstName") + " " + objRS1("LastName") + "</b></font>&nbsp;"

If dayEvents(strMo, strDay) <> "" Then
dayEvents(strMo, strDay) = dayEvents(strMo, strDay) + "<br>" + strName
Else
dayEvents(strMo, strDay) = strName
End If
Loop
' Calendar1_DayRender()
End If

End Sub

Sub MonthChange(ByVal sender As Object, ByVal e As MonthChangedEventArgs)
strCalMo = e.NewDate.Month
strCalDay = e.NewDate.Day
strCalYr = e.NewDate.Year

Dim strConn, strMo, strDay As String
Dim Conn1, Conn2 As SqlConnection
Dim sqlString1, sqlString2 As String
Dim objSelect1, objSelect2 As SqlCommand
Dim objRS1, objRS2 As SqlDataReader

strConn = "server=10.10.2.31;UID=;pwd=;database=Employee"
Conn1 = New SqlConnection(strConn)
Conn1.Open()

sqlString1 = "SELECT * FROM Zak_Employees WHERE Birthday IS NOT NULL ORDER BY Birthday"
objSelect1 = New SqlCommand(sqlString1, Conn1)
objRS1 = objSelect1.ExecuteReader()
'objRS1.Read()

Dim intCtr1, intCtr2 As Integer
For intCtr1 = 0 To 11
For intCtr2 = 0 To 30
dayEvents(intCtr1, intCtr2) = ""
Next
Next

Do While objRS1.Read()
strMo = Month(objRS1("Birthday"))
strDay = Day(objRS1("Birthday"))
strName = "<font color='darkblue'><b>" + objRS1("FirstName") + " " + objRS1("LastName") + "</b></font>&nbsp;"

If dayEvents(strMo, strDay) <> "" Then
dayEvents(strMo, strDay) = dayEvents(strMo, strDay) + "<br>" + strName
Else
dayEvents(strMo, strDay) = strName
End If
Loop
End Sub

Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)

Dim d As CalendarDay
Dim c As TableCell

d = e.Day
c = e.Cell

If d.IsOtherMonth Then
' c.Controls.Clear()
Else
Try
Dim Hol As String = dayEvents(d.Date.Month, d.Date.Day)

If Hol <> "" Then
c.Controls.Add(New LiteralControl("<br><br>" + Hol))
End If
Catch exc As Exception
Response.Write(exc.ToString())
End Try
End If

End Sub
</script>
and here is the calendar code:
<!-- Begin Calendar -->
<font face="arial" size="4" color="gray">
<p>Birthdays <b><FONT face="Verdana, Helvetica, Sans-serif" size="4" color="gold">&rsaquo;</font></b></p>
</font>
<asp:calendar
ID="calBirthdays"
ondayrender="Calendar1_DayRender"
ShowGridLines="true"
NextPrevFormat="FullMonth"
PrevMonthText="Prev Month"
NextMonthText="Next Month"
OnVisibleMonthChanged="MonthChange"

SelectionMode="none"

BackColor="#f0f0f0"
Font-Names="Arial"
Font-Size="X-Large"

TitleFormat="MonthYear"
TitleStyle-ForeColor="gold"
TitleStyle-BackColor="navy"
TitleStyle-Font-Bold="True"
TitleStyle-Font-Size="XX-Large"

DayHeaderStyle-BackColor="#c0c0c0"

DayStyle-HorizontalAlign="right"
DayStyle-VerticalAlign="top"
DayStyle-width="127px"
DayStyle-Height="100px"

DayNameFormat="Short"

TodayDayStyle-BackColor="gold"
TodayDayStyle-ForeColor="black"

OtherMonthDayStyle-ForeColor="gray"
OtherMonthDayStyle-BackColor="white"

runat="server" >

<SelectedDayStyle BorderColor="Gray" />
<TodayDayStyle BackColor="Gold" ForeColor="Black" />
<DayStyle Width="127px" Height="100px" HorizontalAlign="Right" VerticalAlign="Top" BackColor="#CCCCCC" />
<OtherMonthDayStyle BackColor="White" ForeColor="Gray" />

<NextPrevStyle ForeColor="gold"></NextPrevStyle>

<DayHeaderStyle BackColor="Silver" />
<TitleStyle BackColor="Navy" ForeColor="Gold" Font-Size="Small" Font-Bold="True" />

</asp:Calendar>
<!-- End Calendar -->
<code>