Basic Date Picker Documentation

BasicDatePicker.SelectedDate Property

Gets or sets the current selected date of the calendar. Accepts and returns a DateTime object.

[Visual Basic]
Overrides Public Property SelectedDate As Date
[C#]
public override System.DateTime SelectedDate {get; set;}

Property Value

A DateTime object that represents the selected date. The default value is DateTime.MinValue (Null).

Remarks

Use the SelectedDate property to determine the selected date of the BasicDatePicker control.

The SelectedDate property is set using a DateTime object.

A post back event is NOT raised when the user navigates between months.

If AutoPostBack is set to true, when the user selects a date on the calendar, the SelectionChanged event is raised. The SelectedDate property is updated to the selected date.

Example

[Visual Basic, C#] The following example demonstrates how to use the SelectedDate property to get the selected date from the BasicDatePicker control on SelectionChanged and add 7 days.

[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="true" %>
<%@ Register TagPrefix="bdp" Namespace="BasicFrame.WebControls" Assembly="BasicFrame.WebControls.BasicDatePicker" %>
<html>
 <head>
    <title>Basic Date Picker SelectedDate Example</title>
     <script runat="server">
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not IsPostBack Then
                ' Set SelectedDate to Today
                this.BasicDatePicker1.SelectedDate = DateTime.Today
            End If
        End Sub
        
        Sub Selection_Change(sender As Object, e As EventArgs) 
            Dim tempDate As DateTime
            ' Check to see if DateTime object isNull (DateTime.MinValue).
            If Not Me.BasicDatePicker1.IsNull Then
                tempDate = Me.BasicDatePicker1.SelectedDate
                tempDate = tempDate.AddDays(7)
                Response.Write("One week from Today is " + tempDate.ToString("d-MMM-yyyy"))
            Else 
                Response.Write("Invalid Date")
            End If
        End Sub
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker SelectedDate Example</h3>
         >bdp:BasicDatePicker 
             ID="BasicDatePicker1" 
             OnSelectionChanged="Selection_Change" 
             AutoPostBack="true" 
             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 SelectedDate Example</title>
     <script runat="server">
        void Page_Load(Object sender, EventArgs e)
        {
            // Set SelectedDate to Today
            if (!IsPostBack)
                this.BasicDatePicker1.SelectedDate = DateTime.Today;
        }
        
        private void Selection_Change(object sender, EventArgs e)
        {
            DateTime tempDate;
            // Check to see if DateTime object isNull (DateTime.MinValue).
            if (!this.BasicDatePicker1.IsNull) // If it's not null, then create Text for Label.
            {
                tempDate = this.BasicDatePicker1.SelectedDate;
                tempDate = tempDate.AddDays(7);
                Response.Write("One week from Today is " + tempDate.ToString("d-MMM-yyyy"));
            }
            else
            {
                Response.Write("Invalid Date");
            }
        }    
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker SelectedDate Example</h3>
         <bdp:BasicDatePicker 
             ID="BasicDatePicker1" 
             OnSelectionChanged="Selection_Change" 
             AutoPostBack="true" 
             runat="server"></bdp:BasicDatePicker>
     </form>
 </body>
</html>

See Also

BasicDatePicker Class | BasicFrame.WebControls Namespace | VisibleDate | SelectedDateFormatted | AutoPostBack | OnClientAfterSelectionChanged | OnClientBeforeSelectionChanged