Basic Date Picker Documentation

BasicDatePicker.SelectionChanged Event

Occurs when the user selects a new day.

[Visual Basic]
Public Event SelectionChanged As EventHandler
[C#]
public event EventHandler SelectionChanged;

Remarks

This event is raised when the user selects a new day.

Example

[Visual Basic, C#] The following example demonstrates how to specify and code a handler for the SelectionChanged event to get the SelectedDate from the BasicDatePicker control and write to page.

[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="true" %>
<%@ Register TagPrefix="bdp" Namespace="BasicFrame.WebControls" Assembly="BasicFrame.WebControls.BasicDatePicker" %>
<html>
 <head>
    <title>Basic Date Picker SelectionChanged 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
                Response.Write("You picked: " + Me.BasicDatePicker1.SelectedDateFormatted)
            Else 
                Response.Write("Invalid Date")
            End If
        End Sub
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker SelectionChanged 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 SelectionChanged 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.
            {
                Response.Write("You picked: " + this.BasicDatePicker1.SelectedDateFormatted);
            }
            else
            {
                Response.Write("Invalid Date");
            }
        }    
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker SelectionChanged 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 | AutoPostBack | SelectedDate | SelectedDateFormatted | OnSelectionChanged