Solved

dayrender event Calendar Control

Posted on 2004-10-13
1
292 Views
Last Modified: 2008-02-07
Hello I need to disable all dates after a cetain cut of date which is the begiing of the week for the current date. For example if the current date is the Wednesday  13th October. Then i want all dates from  sunday 10th of october disabled. the cut of point is always the sunday for the current week. I have written some code but this seems to disable all dates even ones before 10th October. can anyone help me please.

 Dim dtdisabledate As String
        Dim dtdisabledate2 As String

        dtdisabledate2 = e.Day.Date


        Select Case e.Day.Date.DayOfWeek
            Case DayOfWeek.Monday
                dtdisabledate = e.Day.Date.AddDays(-1)
            Case DayOfWeek.Tuesday
                dtdisabledate = e.Day.Date.AddDays(-2)
            Case DayOfWeek.Wednesday
                dtdisabledate = e.Day.Date.AddDays(-3)
            Case DayOfWeek.Thursday
                dtdisabledate = e.Day.Date.AddDays(-4)
            Case DayOfWeek.Friday
                dtdisabledate = e.Day.Date.AddDays(-5)
            Case DayOfWeek.Saturday
                dtdisabledate = e.Day.Date.AddDays(-6)
            Case DayOfWeek.Sunday
                dtdisabledate = e.Day.Date.AddDays(-6)
        End Select



        ' Add custom text to cell in the Calendar control.
        If e.Day.Date > dtdisabledate Then
            e.Day.IsSelectable = False
        End If
0
Comment
Question by:anwarmir
1 Comment
 
LVL 9

Accepted Solution

by:
msdixon earned 125 total points
ID: 12298144
why are you using a string for "dtdisabledate"? that'll mess things up.

try this :

         dim dtdisabledate as DateTime
         Dim dt as DateTime = DateTime.Today

        Select Case dt.DayOfWeek
            Case DayOfWeek.Monday
                dtdisabledate = dt.AddDays(-2)
            Case DayOfWeek.Tuesday
                dtdisabledate = dt.AddDays(-3)
            Case DayOfWeek.Wednesday
                dtdisabledate = dt.AddDays(-4)
            Case DayOfWeek.Thursday
                dtdisabledate = dt.AddDays(-5)
            Case DayOfWeek.Friday
                dtdisabledate = dt.AddDays(-6)
            Case DayOfWeek.Saturday
                dtdisabledate = dt.AddDays(-7)
            Case DayOfWeek.Sunday
                dtdisabledate = dt.AddDays(-1)
        End Select

         If e.Day.Date > dtdisabledate Then
            e.Day.IsSelectable = False
         End If
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
A short film showing how OnPage and Connectwise integration works.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now