Raises the SelectionChanged event of the BasicDatePicker control and allows you to provide a custom handler for the SelectionChanged event.
Raising an event invokes the event handler through a delegate.
The OnSelectionChanged method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Note When overriding OnSelectionChanged in a derived class, be sure to call the base class's OnSelectionChanged method so that registered delegates receive the event.
[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
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 id="Form1" 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, System.EventArgs e)
{
// Set SelectedDate to Today
if(!IsPostBack)
BasicDatePicker1.SelectedDate = DateTime.Today;
}
private void Selection_Change(object sender, System.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 id="Form1" 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>
BasicDatePicker Class | BasicFrame.WebControls Namespace | SelectionChanged | AutoPostBack | SelectedDate