Disabling some of the days in a Calender

S

Sudhir Pai

Hi,

I have a requirement in the Calender control, that the
user should be able select only dates bewteen TODAY and
NEXT_TWO_WEEKS. All the other remaining days should be
disabled.

How can I customise the Calender Control in order to
achieve this?

Are there any custom controls avaliable?

Thanks

Sudhir
 
K

Ken Cox [Microsoft MVP]

Hi Sudhir,

You can catch the dates as they are being rendered and decide whether to make a
date selectable. Here's an example that might do what you want.

Private Sub Calendar2_DayRender _
(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) _
Handles Calendar2.DayRender
Dim dyDay As CalendarDay
dyDay = e.Day
dyDay.IsSelectable = _
(dyDay.Date >= Date.Today) And _
(dyDay.Date < Now.AddDays(14))
End Sub

Does this help?

Ken
MVP [ASP.NET]


Hi,

I have a requirement in the Calender control, that the
user should be able select only dates bewteen TODAY and
NEXT_TWO_WEEKS. All the other remaining days should be
disabled.

How can I customise the Calender Control in order to
achieve this?

Are there any custom controls avaliable?

Thanks

Sudhir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top