A
AMD Desktop
Hi,
I have a problem and not sure what is going on here, may be the coding is
not proper.
This is a simple page with calendar events.
Everything works fine until I click on View Week link. Then page hangs.
Clicking on a day or Next Month or Previous Month work just fine.
Here is the code:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<%@ Register TagPrefix="enlighten" TagName="clientmenu"
Src="../includes/clientmenu.ascx" %>
<!-- #INCLUDE Virtual="../includes/header.aspx" -->
<!-- #INCLUDE Virtual="../includes/boclient.aspx" -->
<!-- #INCLUDE Virtual="../includes/boadmin.aspx" -->
<!-- #INCLUDE Virtual="../includes/bocalendarevents.aspx" -->
<script language="vb" runat="server">
Dim myClient As New boClient
Dim myAdmin As New boAdmin
Dim myCalendarEvents As New boCalendarEvents
Sub Page_Load
' Setup menu called from custom user control
If Not Request.QueryString("id") Is Nothing Then
pnlClientmenu.Visible = "True"
ascxClientmenu.intID=CInt(Request.QueryString("id"))
End If
pnlSidebarMyResources.Visible = true
' Setup client object datasource
myClient.DSN = ConfigurationSettings.AppSettings("eDSN")
myAdmin.DSN = ConfigurationSettings.AppSettings("eDSN")
myCalendarEvents.DSN = ConfigurationSettings.AppSettings("eDSN")
' Populate dropdown lists and bind data for editing
If Not Page.IsPostBack Then
' here we check if we need to render calendar on a specific Month
If Not Request.QueryString("cdate") Is Nothing Then
calEvents.VisibleDate = Request.QueryString("cdate")
End If
PopulateAndBindData()
End If
End Sub
Sub PopulateAndBindData()
Dim dstClient As DataRow
Dim dstAdmin As DataRow
Try
' Client ID
If Not Request.QueryString("id") Is Nothing Then
viewstate.Add("id", Request.QueryString("id"))
End If
' Administration ID
If Not Request.QueryString("aid") Is Nothing Then
viewstate.Add("aid", Request.QueryString("aid"))
End If
' account types
If Not Request.QueryString("actypeid") Is Nothing Then
viewstate.Add("actypeid", Request.QueryString("actypeid"))
End If
' Get client information; if viewing a specific client's calendar
If Not viewstate("id") Is Nothing Then
dstClient = myClient.getClientName(viewstate("id"))
lblClientName.Text = ": " & dstClient("fname") & " " & dstClient("mname")
& " " & dstClient("lname")
' Get admin information; if viewing a specific admin's calendar
Elseif Not viewstate("aid") Is Nothing Then
dstAdmin = myAdmin.getAdminName(viewstate("aid"))
lblClientName.Text = "for case worker: " & dstAdmin("lname") & ", " &
dstAdmin("fname")
End If
Catch ex As SqlException
lblStatusCalendar.Text = "An error occured loading the client information.
Please contact your manager. <input type='hidden' name='errorString'
value='" & ex.Message & "'>"
End Try
End Sub
Sub Calendar_RenderDay(s As Object, e As dayRenderEventArgs)
Dim dstCalendarEvents As DataSet
Dim ctlCell As TableCell
Dim dtCalendarEvents As DataTable
Dim drCalendarEvents As DataRow
Dim bDayHasEvents As Boolean
ctlCell = e.Cell
Dim dToday As Date
dToday = e.Day.Date.ToString("yyyy/MM/dd")
' Get client information; if viewing a specific client's calendar
If Not viewstate("id") Is Nothing Then
' Get calendar events for this day for a specific client
dstCalendarEvents = myCalendarEvents.getCalendarEvents(viewstate("id"),
dToday)
Elseif Not viewstate("aid") Is Nothing Then
' Get calendar events for this day for a specific administrative user
dstCalendarEvents =
myCalendarEvents.getCalendarEventsForCaseWorker(viewstate("aid"),
viewstate("actypeid"), dToday)
Else
' Get calendar events for this day for all clients
dstCalendarEvents = myCalendarEvents.getCalendarEvents(0, dToday)
End If
' Set dataset results into a datatable to loop through
dtCalendarEvents = dstCalendarEvents.tables("ServicePlanProgramUpdate")
' Loop through events and add to calendar
If Not viewstate("id") Is Nothing Then
' Add client events to calendar, do not show client name since it is the
same
bDayHasEvents = False
For Each drCalendarEvents In dtCalendarEvents.rows
Dim strMinutes As String
If drCalendarEvents("compliance_minutes") < 9 Then
strMinutes = 0 & drCalendarEvents("compliance_minutes")
Else
strMinutes = drCalendarEvents("compliance_minutes")
End If
If viewstate("id") Is Nothing Then
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=c&id=" &
drCalendarEvents("id") & "&spaid=" & drCalendarEvents("spaid") & "&idate=" &
dToday & "'>" & "View" & "</a>)</p>"))
Else
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=clc&id=" &
drCalendarEvents("id") & "&spaid=" & drCalendarEvents("spaid") & "&idate=" &
dToday & "'>" & "View" & "</a>)</p>"))
End If
bDayHasEvents = True
Next
If bDayHasEvents Then
ctlCell.BackColor=System.Drawing.Color.FromArgb(60, 160, 220)
End If
Else
' Add events to calendar, show client name since it is different
bDayHasEvents = False
For Each drCalendarEvents In dtCalendarEvents.rows
Dim strMinutes As String
If drCalendarEvents("compliance_minutes") < 9 Then
strMinutes = 0 & drCalendarEvents("compliance_minutes")
Else
strMinutes = drCalendarEvents("compliance_minutes")
End If
If Not viewstate("aid") Is Nothing Then
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=ca" &
"&aid=" & viewstate("aid") & "&id=" & drCalendarEvents("id") & "&spaid=" &
drCalendarEvents("spaid") & "&idate=" & dToday & "'>" &
drCalendarEvents("client_name") & "</a>)</p>"))
Else
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=c&id=" &
drCalendarEvents("id") & "&spaid=" & drCalendarEvents("spaid") & "&idate=" &
dToday & "'>" & drCalendarEvents("client_name") & "</a>)</p>"))
End If
bDayHasEvents = True
Next
If bDayHasEvents Then
ctlCell.BackColor=System.Drawing.Color.FromArgb(60, 160, 220)
End If
End If
End Sub
Sub Calendar_SelectionChanged(s As Object, e As EventArgs)
Dim dCurrentDate As DateTime
dCurrentDate = calEvents.SelectedDate
If Not viewstate("aid") Is Nothing Then
' week is selected
If calEvents.SelectedDates.Count = 7 Then
Response.Redirect("../caseworker/viewcalendarevents.aspx?aid=" &
viewstate("aid") & "&idate=" & dCurrentDate & "&mode=w")
Else
Response.Redirect("../caseworker/viewcalendarevents.aspx?aid=" &
viewstate("aid") & "&idate=" & dCurrentDate & "&mode=d")
End If
Else If Not viewstate("id") Is Nothing Then
' week Is selected
If calEvents.SelectedDates.Count = 7 Then
Response.Redirect("../caseworker/viewcalendarevents.aspx?id=" &
viewstate("id") & "&idate=" & dCurrentDate & "&mode=w")
Else
Response.Redirect("../caseworker/viewcalendarevents.aspx?id=" &
viewstate("id") & "&idate=" & dCurrentDate & "&mode=d")
End If
Else
If calEvents.SelectedDates.Count = 7 Then
Response.Redirect("../caseworker/viewcalendarevents.aspx?idate=" &
dCurrentDate & "&mode=w")
Else
Response.Redirect("../caseworker/viewcalendarevents.aspx?idate=" &
dCurrentDate & "&mode=d")
End If
End If
End Sub
</script>
<p>
<strong>View Calendar <asp:label id="lblClientName" runat="server" Text=""
/>
</strong>
</p>
<!--- Menu --->
<aspanel ID="pnlClientmenu" Visible="false" RunAt="server">
<enlighten:clientmenu id="ascxClientmenu" intID=0 RunAt="server" />
</aspanel>
<form runat="server">
<p>
<asp:label ID="lblStatusCalendar" RunAt="server" />
<!-- Calendar -->
<ASP:Calendar
Width="100%"
CellPadding="10"
ID="calEvents"
ShowGridLines="true"
DayStyle-BackColor="lightblue"
TodaydayStyle-BackColor="lightyellow"
WeekendDayStyle-BackColor="lightgrey"
SelectionMode="DayWeekMonth"
SelectWeekText="View Week"
OnSelectionChanged="Calendar_SelectionChanged"
OnDayRender="Calendar_RenderDay"
PrevMonthText="Previous Month"
NextMonthText="Next Month"
RunAt="Server" />
</p>
</form>
<!-- #INCLUDE Virtual="../includes/footer.aspx" -->
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thank you,
Gene
I have a problem and not sure what is going on here, may be the coding is
not proper.
This is a simple page with calendar events.
Everything works fine until I click on View Week link. Then page hangs.
Clicking on a day or Next Month or Previous Month work just fine.
Here is the code:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<%@ Register TagPrefix="enlighten" TagName="clientmenu"
Src="../includes/clientmenu.ascx" %>
<!-- #INCLUDE Virtual="../includes/header.aspx" -->
<!-- #INCLUDE Virtual="../includes/boclient.aspx" -->
<!-- #INCLUDE Virtual="../includes/boadmin.aspx" -->
<!-- #INCLUDE Virtual="../includes/bocalendarevents.aspx" -->
<script language="vb" runat="server">
Dim myClient As New boClient
Dim myAdmin As New boAdmin
Dim myCalendarEvents As New boCalendarEvents
Sub Page_Load
' Setup menu called from custom user control
If Not Request.QueryString("id") Is Nothing Then
pnlClientmenu.Visible = "True"
ascxClientmenu.intID=CInt(Request.QueryString("id"))
End If
pnlSidebarMyResources.Visible = true
' Setup client object datasource
myClient.DSN = ConfigurationSettings.AppSettings("eDSN")
myAdmin.DSN = ConfigurationSettings.AppSettings("eDSN")
myCalendarEvents.DSN = ConfigurationSettings.AppSettings("eDSN")
' Populate dropdown lists and bind data for editing
If Not Page.IsPostBack Then
' here we check if we need to render calendar on a specific Month
If Not Request.QueryString("cdate") Is Nothing Then
calEvents.VisibleDate = Request.QueryString("cdate")
End If
PopulateAndBindData()
End If
End Sub
Sub PopulateAndBindData()
Dim dstClient As DataRow
Dim dstAdmin As DataRow
Try
' Client ID
If Not Request.QueryString("id") Is Nothing Then
viewstate.Add("id", Request.QueryString("id"))
End If
' Administration ID
If Not Request.QueryString("aid") Is Nothing Then
viewstate.Add("aid", Request.QueryString("aid"))
End If
' account types
If Not Request.QueryString("actypeid") Is Nothing Then
viewstate.Add("actypeid", Request.QueryString("actypeid"))
End If
' Get client information; if viewing a specific client's calendar
If Not viewstate("id") Is Nothing Then
dstClient = myClient.getClientName(viewstate("id"))
lblClientName.Text = ": " & dstClient("fname") & " " & dstClient("mname")
& " " & dstClient("lname")
' Get admin information; if viewing a specific admin's calendar
Elseif Not viewstate("aid") Is Nothing Then
dstAdmin = myAdmin.getAdminName(viewstate("aid"))
lblClientName.Text = "for case worker: " & dstAdmin("lname") & ", " &
dstAdmin("fname")
End If
Catch ex As SqlException
lblStatusCalendar.Text = "An error occured loading the client information.
Please contact your manager. <input type='hidden' name='errorString'
value='" & ex.Message & "'>"
End Try
End Sub
Sub Calendar_RenderDay(s As Object, e As dayRenderEventArgs)
Dim dstCalendarEvents As DataSet
Dim ctlCell As TableCell
Dim dtCalendarEvents As DataTable
Dim drCalendarEvents As DataRow
Dim bDayHasEvents As Boolean
ctlCell = e.Cell
Dim dToday As Date
dToday = e.Day.Date.ToString("yyyy/MM/dd")
' Get client information; if viewing a specific client's calendar
If Not viewstate("id") Is Nothing Then
' Get calendar events for this day for a specific client
dstCalendarEvents = myCalendarEvents.getCalendarEvents(viewstate("id"),
dToday)
Elseif Not viewstate("aid") Is Nothing Then
' Get calendar events for this day for a specific administrative user
dstCalendarEvents =
myCalendarEvents.getCalendarEventsForCaseWorker(viewstate("aid"),
viewstate("actypeid"), dToday)
Else
' Get calendar events for this day for all clients
dstCalendarEvents = myCalendarEvents.getCalendarEvents(0, dToday)
End If
' Set dataset results into a datatable to loop through
dtCalendarEvents = dstCalendarEvents.tables("ServicePlanProgramUpdate")
' Loop through events and add to calendar
If Not viewstate("id") Is Nothing Then
' Add client events to calendar, do not show client name since it is the
same
bDayHasEvents = False
For Each drCalendarEvents In dtCalendarEvents.rows
Dim strMinutes As String
If drCalendarEvents("compliance_minutes") < 9 Then
strMinutes = 0 & drCalendarEvents("compliance_minutes")
Else
strMinutes = drCalendarEvents("compliance_minutes")
End If
If viewstate("id") Is Nothing Then
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=c&id=" &
drCalendarEvents("id") & "&spaid=" & drCalendarEvents("spaid") & "&idate=" &
dToday & "'>" & "View" & "</a>)</p>"))
Else
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=clc&id=" &
drCalendarEvents("id") & "&spaid=" & drCalendarEvents("spaid") & "&idate=" &
dToday & "'>" & "View" & "</a>)</p>"))
End If
bDayHasEvents = True
Next
If bDayHasEvents Then
ctlCell.BackColor=System.Drawing.Color.FromArgb(60, 160, 220)
End If
Else
' Add events to calendar, show client name since it is different
bDayHasEvents = False
For Each drCalendarEvents In dtCalendarEvents.rows
Dim strMinutes As String
If drCalendarEvents("compliance_minutes") < 9 Then
strMinutes = 0 & drCalendarEvents("compliance_minutes")
Else
strMinutes = drCalendarEvents("compliance_minutes")
End If
If Not viewstate("aid") Is Nothing Then
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=ca" &
"&aid=" & viewstate("aid") & "&id=" & drCalendarEvents("id") & "&spaid=" &
drCalendarEvents("spaid") & "&idate=" & dToday & "'>" &
drCalendarEvents("client_name") & "</a>)</p>"))
Else
ctlCell.Controls.Add(New LiteralControl("<p>" &
drCalendarEvents("compliance_hour") & ":" & strMinutes &
drCalendarEvents("compliance_ampm") & " " & drCalendarEvents("activity") & "
(<a href='http://www.mypage.com/caseworker/viewactivity.aspx?view=c&id=" &
drCalendarEvents("id") & "&spaid=" & drCalendarEvents("spaid") & "&idate=" &
dToday & "'>" & drCalendarEvents("client_name") & "</a>)</p>"))
End If
bDayHasEvents = True
Next
If bDayHasEvents Then
ctlCell.BackColor=System.Drawing.Color.FromArgb(60, 160, 220)
End If
End If
End Sub
Sub Calendar_SelectionChanged(s As Object, e As EventArgs)
Dim dCurrentDate As DateTime
dCurrentDate = calEvents.SelectedDate
If Not viewstate("aid") Is Nothing Then
' week is selected
If calEvents.SelectedDates.Count = 7 Then
Response.Redirect("../caseworker/viewcalendarevents.aspx?aid=" &
viewstate("aid") & "&idate=" & dCurrentDate & "&mode=w")
Else
Response.Redirect("../caseworker/viewcalendarevents.aspx?aid=" &
viewstate("aid") & "&idate=" & dCurrentDate & "&mode=d")
End If
Else If Not viewstate("id") Is Nothing Then
' week Is selected
If calEvents.SelectedDates.Count = 7 Then
Response.Redirect("../caseworker/viewcalendarevents.aspx?id=" &
viewstate("id") & "&idate=" & dCurrentDate & "&mode=w")
Else
Response.Redirect("../caseworker/viewcalendarevents.aspx?id=" &
viewstate("id") & "&idate=" & dCurrentDate & "&mode=d")
End If
Else
If calEvents.SelectedDates.Count = 7 Then
Response.Redirect("../caseworker/viewcalendarevents.aspx?idate=" &
dCurrentDate & "&mode=w")
Else
Response.Redirect("../caseworker/viewcalendarevents.aspx?idate=" &
dCurrentDate & "&mode=d")
End If
End If
End Sub
</script>
<p>
<strong>View Calendar <asp:label id="lblClientName" runat="server" Text=""
/>
</strong>
</p>
<!--- Menu --->
<aspanel ID="pnlClientmenu" Visible="false" RunAt="server">
<enlighten:clientmenu id="ascxClientmenu" intID=0 RunAt="server" />
</aspanel>
<form runat="server">
<p>
<asp:label ID="lblStatusCalendar" RunAt="server" />
<!-- Calendar -->
<ASP:Calendar
Width="100%"
CellPadding="10"
ID="calEvents"
ShowGridLines="true"
DayStyle-BackColor="lightblue"
TodaydayStyle-BackColor="lightyellow"
WeekendDayStyle-BackColor="lightgrey"
SelectionMode="DayWeekMonth"
SelectWeekText="View Week"
OnSelectionChanged="Calendar_SelectionChanged"
OnDayRender="Calendar_RenderDay"
PrevMonthText="Previous Month"
NextMonthText="Next Month"
RunAt="Server" />
</p>
</form>
<!-- #INCLUDE Virtual="../includes/footer.aspx" -->
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thank you,
Gene