Solved

dayrender event Calendar Control

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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