Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar - extra week displayed 1

Status
Not open for further replies.

ShikkurDude

Programmer
Mar 15, 2005
55
US
My Calendar control always displays 6 weeks per month. I understand one extra is for the partial week that's in this month and part of it's in the other (prior or next) month, but there's always yet another week that's totally in the next (or previous) month. How do I get rid of that completely extra week?

Thanks,
E.
 
Yes, that works, too.

Here's my DayRender:
Code:
	Private Sub DayRender(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles cldPHOEvents.DayRender

		Dim dayHTMLFromDB As String = BuildDayHTMLFromDB(e.Day.Date)

		RemoveExtraWeek(sender, e)
		ColorWeeks(e)

		e.Cell.HorizontalAlign = HorizontalAlign.Left
		e.Cell.VerticalAlign = VerticalAlign.Top
		e.Cell.Height = System.Web.UI.WebControls.Unit.Parse(75)
		e.Cell.Font.Size = New System.wEb.UI.WebControls.FontUnit(FontSize.XXSmall)
		e.Cell.ForeColor = Color.Blue

		e.Cell.Text = "<font size=2>"

		If dayHTMLFromDB <> "" Then	   'there's something scheduled for that day -> make it clickable
			e.Cell.Text &= "<span style=""cursor:hand"" onclick=""window.open('PHODayPopup.aspx?RequestedDate=" & e.Day.Date & "','PopupWindow', 'width=550, height=600, menubar=yes, resizable=yes, "
			e.Cell.Text &= "scrollbars=yes, "
			e.Cell.Text &= "toolbar=no, status=no')""><b><u>" & e.Day.Date.Day & "</u></b></span><center>" & dayHTMLFromDB & "</center></font>"
		Else		  'nothing scheduled - just display unclickable date
			e.Cell.Text &= "<b>" & e.Day.Date.Day & "</b>"
		End If

		e.Cell.Style.Add("menubar", "yes")
		e.Cell.Style.Add("resizable", "yes")
		e.Cell.Style.Add("scrollbars", "yes")
		e.Cell.Style.Add("toolbar", "yes")
		e.Cell.Style.Add("status", "yes")

		If e.Day.IsOtherMonth = False Then
			Session("selectedMonth") = e.Day.Date.Month.ToString
			Session("selectedYear") = e.Day.Date.Year.ToString
		End If
	End Sub
I'm putting your DayRender code into my "RemoveExtraWeek" sub:
Code:
	Private Sub RemoveExtraWeek(ByVal sender As System.Object, ByRef e As System.Web.UI.WebControls.DayRenderEventArgs)
		If e.Day.Date.DayOfWeek = DayOfWeek.Sunday Then
			If e.Day.Date.Month <> CType(sender, Calendar).VisibleDate.Month And _
			e.Day.Date.AddDays(6).Month <> CType(sender, Calendar).VisibleDate.Month Then
				Dim lit As New Literal
				lit.Text = "<script id='" & e.Day.Date.Ticks.ToString & "'>window.setTimeout('document.getElementById(\'" & e.Day.Date.Ticks.ToString & "\').parentNode.parentNode.style.display=\'none\'',50);</script>"
				e.Cell.Controls.Add(lit)
			End If
		End If
	End Sub
Thanks again,
Dot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top