Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hello!

 

I'm trying to make the calendar control of asp.net to show week numbers.

So far I have been able to produce correct week numbers (in Finland) and add them to the preferred first day of week cell. This is however very inconvenient because then the weeknumber goes between the first and the second day (monday and tuesday in Finland) or under the first day.

 

Now I would like to have the weeknumber in the week selection cell where you can set a nonchangein value (SelectWeekText=""). Or If there is a way to add a cell to every week on the same row before the first weekday cell or the selectweek cell.

 

Can anyone tell if this is possible?

And how to do it if it is possible?

Or is there any workarounds to show any data in a calendar control outside the day cells?

 

Now I have a normal calendar control like '<asp:calendar ... onDayRender="Calendar_DayRender" ../>'.

 

And here I have the week calculation.

So I am now using the ondayrender to calculate the week number from the date, but I cant access week selection cell from there.

 
  Sub Calendar_DayRender(source As Object, e As DayRenderEventArgs) 
  Dim d As CalendarDay 
  d = e.Day 
   
  ' Formatting the weeknumber into to calendar. 
  If weekday(d.Date) = 2 Then 
	' Calculating the weeknumber for the calendar. 
	Dim DayAmount As Integer = datediff("d", "1.1."&year(d.Date), dateadd("d",1,d.Date)) 
	Dim ThisWeek As Integer 
Dim wkd As Integer = weekday("1.1."&year(d.date)) 
Select Wkd 
	Case "1" DayAmount = DayAmount-1 'Sunday 
		Case "2" DayAmount = DayAmount 'Monday 
	Case "3" DayAmount = DayAmount+1 'Tuesday 
		Case "4" DayAmount = DayAmount+2 'Wednesday 
	Case "5" DayAmount = DayAmount+3 'Thurday 
	Case "6" DayAmount = DayAmount-3 'Friday 
		Case "7" DayAmount = DayAmount-2 'Saturday
	End Select 
ThisWeek = DayAmount / 7 + 1 
e.Cell.HorizontalAlign = 1 
e.Cell.Controls.Add(New LiteralControl(Thisweek)) 
  End If 
  End Sub
  

Edited by Jore
  • 2 weeks later...
Posted

Yes it is possible. I have done it. Give me a bit and I will find my code. Will probably be late tonight or tomorrow before I can find it. (its at home and I am at work)

I found my solution for this on the microsoft website. If that helps any.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...