Solved

dayrender event Calendar Control

Posted on 2004-10-13
1
287 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

18 Experts available now in Live!

Get 1:1 Help Now