Calendar Control In ASP.Net

Here, I would like to describe the most usefull properties of the Calendar control in ASP.NET. I will also describe how to add custom and user related data to a calendar control. I will describe that below.

  • How to customize the view (look) of a Calendar control from the default view
  • How to add dynamically other (ASP.NET) controls (like Label, TextBox and so on.) to a Calendar control
  • How to disable the previous day in a calendar control
  • How to restrict access of month(s) date (apply validation).
  • How to add user-specific data to a calendar control

1. How to customize the view (look) of a Calendar control from the default view

  • Drag and drop a Calendar control from the toolbox to your web page.



  • Change the view of the Calendar control. Here I need to use some property of the Calendar control to use other properties depending on your requirements.



  • After customization the view of the calendar control would be like this:


2. How to dynamically add another (ASP.NET) control (like Label, TextBox and so on) in a Calendar control

  • Go to the Properties window of the Calendar control then Double-click on the Day render event of the calendar control.



  • Then write this code in the day render method.



  • Then you can see the output look like this:


3. How to disable the previous day of the calendar control

  • Write this code to disable a day click in the Calendar control. Write this code in the day render method.



  • Then you can see the output like this: Here you can see the date before the current date is not selectable.


4. How to restrict access of the month(s) date (apply validation)



5. How to add user-specific data to the Calendar control

  • First prepare the specific data to be displayed on the date of the Calendar control.
    Write this method:



  • Call this method for the page load event of the page.



  • Write this code in the Day render method of the Calendar control.



  • Then you will see output look like this:


This is my complete demo. I think it’s helpful for you. Download the attached application for the complete demo.


Similar Articles