AjaxCalendarExtender

AjaxCalendar is an ASP.NET AJAX extender that can be attached to any ASP:TextBox control to provide client-side date-picking functionality with customizable date-format and provide an UI in a popup control. You can interact with these calendar by selecting on a day to set the date, or ‘Today’ link to set the current date.

Some important properties of AjaxCalendarExtender:

  1. TargetControlID: The ASP:TextBox control ID where want to show calendar when user click on TextBox.

  2. DefaultView: Default view of the calendar when it first popup (Days, Months or Years).

  3. PopupPosition: It indicate where you want the calendar displayed (bottom, left, top or right).

  4. StartDate: Minimum date that user can select.

  5. EndDate: Maximum date that user can select.

  6. SelectedDate: Date to be initially filled in TextBox.

Aspx Page coding:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head runat="server">
  6. <title></title>
  7. </head>
  8. <body>
  9. <form id="form1" runat="server">
  10. <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
  11. </asp:ToolkitScriptManager>
  12. <div>
  13. <asp:CalendarExtender ID="CalendarExtender1" runat="server"
  14. TargetControlID="txtDate" PopupPosition="Right" EndDate="8/10/2015"
  15. StartDate="2012-03-03" TodaysDateFormat="d MMMM, yyyy"
  16. SelectedDate="8/10/2015">
  17. </asp:CalendarExtender>
  18. <asp:TextBox runat="server" ReadOnly="true" ID="txtDate">
  19. </asp:TextBox>
  20. </div>
  21. </form>
  22. </body>
  23. </html>
Output

Calendar

Note: You need to use the Ajax Control Toolkit library.