?
Solved

dayrender event Calendar Control

Posted on 2004-10-13
1
Medium Priority
?
312 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 375 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

862 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