Basic Date Picker Documentation

BasicDatePicker.SpecialDates Property

Gets or sets the ControlId of the SpecialDates object.

[Visual Basic]
Public Property SpecialDates As String
[C#]
public string SpecialDates {get; set;}

Property Value

Default value is String.Empty.

Remarks

Use the SpecialDates property to link a BasicFrame.WebControls.SpecialDates web control to a BasicDatePicker control. One SpecialDates web control can be linked to many BasicDatePicker controls using the BasicDatePicker.SpecialDates property.

The SpecialDates control holds a collection of SpecialDate objects. A SpecialDate appears bold by default, although can be highly customized using the Style editor or custom OnClientDayRender client-side function.

SpecialDates web controls can be used to mark items like Appointments or Holidays on the calendar. By default the Text property of the SpecialDate object is applied to the ToolTip attribute of the table cell.

Note   The number of SpecialDate objects within the SpecialDates collection should be kept to a minimum to avoid client-side performance issues. Performace testing is highly recommended and can vary widely depending on quality of client machine.

SpecialDate objects can be added programatically via the code-behind or through the SpecialDate Collection Editor. It is typical that SpecialDate objects will be created dynamically in the code behind as the Collection Editor requires Date values to be constants.

Example

[Visual Basic, C#] The following example demonstrates how to specify the VisibleDate property to programmatically set the value that determines the month that is displayed in the BasicDatePicker control.

[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="true" %>
<%@ Register TagPrefix="bdp" Namespace="BasicFrame.WebControls" Assembly="BasicFrame.WebControls.BasicDatePicker" %>
<html>
 <head>
    <title>Basic Date Picker SpecialDates Example</title>
     <script runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)
        ' Set SelectedDate to Today.
        If Not IsPostBack Then
            this.BasicDatePicker1.SelectedDate = DateTime.Today
        End If
    End Sub

    Sub Button1_Click(sender As Object, e As EventArgs) 
        Dim message As String = String.Empty

        ' Check to see if DateTime object isNull (DateTime.MinValue).
        If Not Me.BasicDatePicker1.IsNull Then
            ' Option #1
            ' .SelectedDateFormatted automatically converts the SelectedDate 
            ' to a string and formats according to the DateFormat.
            ' message = this.BasicDatePicker1.SelectedDateFormatted;

            ' Option #2
            ' The SelectedDate could also be converted to a String manually.
            message = Me.BasicDatePicker1.SelectedDate.ToString("MMMM dd, yyyy")

        Else
            message = "No Date."
        End If

        ' Check to determine if the SelectedDate is contained in the SpecialDates Collection.
        If Me.SpecialDates1.Dates.Contains(Me.BasicDatePicker1.SelectedDate) Then
            message += "<br />This is a SpecialDate"
        Else
            message += "<br />This is <strong>NOT</strong> a SpecialDate"
        End If

        this.Label1.Text = "You picked: <strong>" + message + "</strong>"
    End Sub

    Sub LinkButton1_Click(sender As Object, e As EventArgs) 
        ' If any SpecialDate object exist, then print list to screen.
        If Me.SpecialDates1.Dates.Count > 0 Then
            Dim temp As String = String.Empty
            Dim specialDate As specialDate
            For Each specialDate In Me.SpecialDates1.Dates
                temp += specialDate.Date.ToLongDateString() + " - " + specialDate.Text + "<br />"
            Next
            Me.lblSpecialDates.Text = temp
        End If        
    End Sub

    ' Add SpecialDates.
    Private Sub Page_Init(sender As Object, e As EventArgs) 
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(-16), "Presentation with Partners.", True, String.Empty))
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(-2), "Holiday", False, String.Empty))
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(-1), "Review customer agreements.", True, String.Empty))
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(1), "Follow-up new sales.", True, String.Empty))
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(1), "Lunch with Sales department.", True, String.Empty))
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(4), "Send final version of customer agreements.", True, String.Empty))
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(5), "Holiday", False, String.Empty))
        Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(14), "Closed", False, "bdpSpecialDateLite"))
    End Sub
     
    Sub BasicDatePicker1_SelectionChanged(sender As Object, e As EventArgs) 
        ' Write SelectedDate to page.
        Response.Write(Me.BasicDatePicker1.SelectedDateFormatted)
    End Sub
        
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker SpecialDates Example</h3>
         >bdp:BasicDatePicker ID="BasicDatePicker1" runat="server"></bdp:BasicDatePicker>
     </form>
 </body>
</html>

[C#]
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register TagPrefix="bdp" Namespace="BasicFrame.WebControls" Assembly="BasicFrame.WebControls.BasicDatePicker" %>
<html>
 <head>
    <title>Basic Date Picker SpecialDates Example</title>
     <script runat="server">
     void Page_Load(Object sender, EventArgs e)
     {
        // Set SelectedDate to Today
        if (!IsPostBack)
            this.BasicDatePicker1.SelectedDate = DateTime.Today;
     }

    protected void Button1_Click(Object sender, EventArgs e)
    {
        string message = "";

        // Check to see if DateTime object isNull (DateTime.MinValue).
        if (!this.BasicDatePicker1.IsNull) // If it's not null, then create Text for Label.
        {
            // Option #1
            // .SelectedDateFormatted automatically converts the SelectedDate 
            // to a string and formats according to the DateFormat.
            // message = this.BasicDatePicker1.SelectedDateFormatted;

            // Option #2
            // The SelectedDate could also be converted to a String manually.
            message = this.BasicDatePicker1.SelectedDate.ToString("MMMM dd, yyyy");
               
        }
        else
        {
            message = "No Date.";
        }

        // Check to determine if the SelectedDate is contained in the SpecialDates Collection.
        if (this.SpecialDates1.Dates.Contains(this.BasicDatePicker1.SelectedDate))
            message += "<br />This is a SpecialDate";
        else
            message += "<br />This is <strong>NOT</strong> a SpecialDate";
       
        this.Label1.Text = "You picked: <strong>" + message + "</strong>";
    }

    private void LinkButton1_Click(Object sender, EventArgs e)
    {
        // If any SpecialDate object exist, then print list to screen.
        if (this.SpecialDates1.Dates.Count > 0)
        {
            string temp = string.Empty;
            foreach(SpecialDate date in this.SpecialDates1.Dates)
            {
                temp += date.Date.ToLongDateString() + " - " + date.Text + "<br />";
            }
            this.lblSpecialDates.Text = temp;
        }
    }
     
     // Add SpecialDates.
    override protected void OnInit(EventArgs e)
    {
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(-16),"Presentation with Partners.",true,string.Empty));
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(-2),"Holiday",false,string.Empty));
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(-1),"Review customer agreements.",true,string.Empty));
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(1),"Follow-up new sales.",true,string.Empty));
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(1),"Lunch with Sales department.",true,string.Empty));
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(4),"Send final version of customer agreements.",true,string.Empty));
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(5),"Holiday",false,string.Empty));
        this.SpecialDates1.Dates.Add(new SpecialDate(DateTime.Today.AddDays(14),"Closed",false,"bdpSpecialDateLite"));
        
        base.OnInit(e);
    }
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker SpecialDates Example</h3>
          <p><bdp:BasicDatePicker ID="BasicDatePicker1" runat="server" SpecialDatesID="SpecialDates1"></bdp:BasicDatePicker>
               <bdp:specialdates ID="SpecialDates1" runat="server"></bdp:specialdates></p>
           <p><asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Button"></asp:Button></p>
           <p><asp:Label ID="Label1" runat="server"></asp:Label></p>
           <p><asp:LinkButton ID="btnSpecialDates" OnClick="LinkButton1_Click" runat="server">List Special Dates</asp:LinkButton></p>
           <p><asp:Label ID="lblSpecialDates" runat="server"></asp:Label></p>
     </form>
 </body>
</html>

See Also

BasicDatePicker Class | BasicFrame.WebControls Namespace | OnClientDayRender