Welcome Guest Search | Active Topics | Sign In | Register

Getting the 1st and/ or last date displayed in the calendar Options
gmyroup
Posted: Tuesday, October 13, 2009 2:13:05 PM
Rank: Advanced Member
Groups: Member

Joined: 7/26/2009
Posts: 36
Is their a property that I can check to get (at the very least) the 1st date displayed on the calendar? I need to repopulate the calendar with data when the user moves to a different month using the scroll event. I looked in the calendar properties but did not see anything that would help me.
eo_support
Posted: Tuesday, October 13, 2009 2:39:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

There isn't. You can use the following code to get the first and last visible date on the Calendar for any given month:

Code: C#
//Get the first visible date. month is the first day of the month
private DateTime GetFirstVisibleDate(
    EO.Web.Calendar calendar, DateTime month)
{
    int nDay = (int)month.DayOfWeek;
    int nFirstDayOfWeek = (int)calendar.FirstDayOfWeek;
    int nOffset = 0;
    if (nFirstDayOfWeek > nDay)
        nOffset -= 7;
    nOffset -= nDay - nFirstDayOfWeek;
    return month.AddDays(nOffset);
}

//Get the last visible date. month is the first day of the month
private DateTime GetLastVisibleDate(
    EO.Web.Calendar calendar, DateTime month)
{
    DateTime date = GetFirstVisibleDate(calendar, month);
    return date.AddDays(7 * 6 - 1);
}

Thanks
gmyroup
Posted: Tuesday, October 13, 2009 3:47:32 PM
Rank: Advanced Member
Groups: Member

Joined: 7/26/2009
Posts: 36
What about when you scroll to a new month. Do the days render again?
gmyroup
Posted: Tuesday, October 13, 2009 4:05:41 PM
Rank: Advanced Member
Groups: Member

Joined: 7/26/2009
Posts: 36
OK... I need to use the dayrender event to place html in the cell which I figured out how to do (see attached code) but after I do I am not able to select (catching the serverside selectionchanged event) the date in order to update it. Any thoughts as to why not?

Dim cd As Integer = 0
Dim htmlText As String = String.Empty
Dim sb As StringBuilder = Nothing
Dim dayofmonth As String
Dim Vehicle1 As String = String.Empty
Dim Vehicle2 As String = String.Empty
Dim Vehicle3 As String = String.Empty
Dim TimeOfDay1 As String = String.Empty
Dim TimeOfDay2 As String = String.Empty
Dim TimeOfDay3 As String = String.Empty

If Schedules Is Nothing Then
Call FillVanSchedule(Me.Page, e.Day.Date) 'this fills an array I use to keep important dates to be rendered
End If
sb = New StringBuilder
dayofmonth = e.Day.DayNumberText
e.Day.IsSelectable = True
For cd = 0 To 34
If Not Schedules(cd, 1) Is Nothing Then
If Convert.ToDateTime(Schedules(cd, 1)) = e.Day.Date Then
Vehicle1 = Schedules(cd, 2) & ":"
TimeOfDay1 = Schedules(cd, 3)
If Schedules(cd, 1) = Schedules(cd + 1, 1) Then
Vehicle2 = Schedules(cd + 1, 2) & ":"
TimeOfDay2 = Schedules(cd + 1, 3)
Else
Vehicle2 = String.Empty
TimeOfDay2 = String.Empty
End If
If Schedules(cd, 1) = Schedules(cd + 2, 1) Then
Vehicle3 = Schedules(cd + 2, 2) & ":"
TimeOfDay3 = Schedules(cd + 2, 3)
Else
Vehicle3 = String.Empty
TimeOfDay3 = String.Empty
End If
sb.Append("<table style='font-size: x-small; font-family: Arial, Sans-Serif vertical-align: top; text-align: left; border-collapse: collapse;'>")
sb.AppendLine()
sb.Append("<tr><td style='font-weight: bold; font-size: small; padding-bottom: 5px; width: 100px'>")
sb.AppendLine()
sb.Append(e.Day.DayNumberText & "</td></tr>")
sb.AppendLine()
sb.Append("<tr><td style='width: 100px'>" & Vehicle1 & "&nbsp;" & TimeOfDay1 & "</td></tr>")
sb.AppendLine()
sb.Append("<tr><td style='width: 100px'>" & Vehicle2 & "&nbsp;" & TimeOfDay2 & "</td></tr>")
sb.AppendLine()
sb.Append("<tr><td style='width: 100px'>" & Vehicle3 & "&nbsp;" & TimeOfDay3 & "</td></tr></table>")
sb.AppendLine()
e.Writer.Write(sb.ToString)
Exit For
End If
Else
sb.Append("<table style='font-size: x-small; font-family: Arial, Sans-Serif vertical-align: top; text-align: left;'>")
sb.AppendLine()
sb.Append("<tr><td style='font-weight: bold; font-size: small; padding-bottom: 5px; width: 100px'>")
sb.AppendLine()
sb.Append(e.Day.DayNumberText & "</td></tr>")
sb.AppendLine()
sb.Append("<tr><td style='width: 100px'></td></tr>")
sb.AppendLine()
sb.Append("<tr><td style='width: 100px'></td></tr>")
sb.AppendLine()
sb.Append("<tr><td style='width: 100px'></td></tr></table>")
sb.AppendLine()
e.Writer.Write(sb.ToString)
Exit For
End If
Next
eo_support
Posted: Tuesday, October 13, 2009 4:17:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Check whether you have AutoPostBackOnSelect is set to true. If that is not the problem, please create a full test page that demonstrates the problem, once we have that, we will try to run it here and see if we see the same problem. Please make sure the test page runs and only contain the code necessary to demonstrate the problem.

Thanks
gmyroup
Posted: Tuesday, October 13, 2009 4:34:21 PM
Rank: Advanced Member
Groups: Member

Joined: 7/26/2009
Posts: 36
Thanks! I found that taking the calendar OUT of the callbackpanel I had it in made everything work as I expect it would. Should the callbackpanel cause the calendar to not respond to the mouseover and selection events?

Now my problem is I don't have a way to identify the calendarday the user selected so I can update it after the user specifies new text to appear in the selected days cell. Also, how could I cause the calendar control to render so the newly added data will appear?
eo_support
Posted: Tuesday, October 13, 2009 5:09:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You never cause the calendar control (or any other control) to render. You post back the whole page and the whole page is re-rendered. After that you will have the choice to apply the change completely or partially. The former is a regular page reload and the later is what UpdatePanel/CallbackPanel does. In another word, you do not have the option to update one cell only (thus there is no need to identify the selected day cell). All you do is to handle DayRender event and when the Calendar needs to update, it calls your DayRender event for all the dates it needs to show.

CallbackPanel affects what changes are applied (which portion of the page is updated), it does not affect what event is fired.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.