Solved

dayrender event Calendar Control

Posted on 2004-10-13
1
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…

738 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