Basic Date Picker Documentation

BasicDatePicker.IsDate Property

Gets a value indicating whether the posted text can be parsed into a valid DateTime object. If the text value can not be parsed into a DateTime object based on the DateFormat, then false is returned.

[Visual Basic]
Public ReadOnly Property IsDate As Boolean
[C#]
public bool IsDate {get;}

Property Value

false if the PostedText can not be parsed into a valid DateTime object, otherwise true.

Remarks

Use the IsDate to determine if value supplied in TextBox could be converted into a valid DateTime object. If the TextBox value could not be parsed into a DateTime object, IsDate will be false.

Note   You can get the exact string value entered into the TextBox with the PostedText property. The PostedText property could then be used in a validation message sent to the page.

Example

[Visual Basic, C#] The following example demonstrates how to use the IsDate property to check whether the value entered was a valid date.

[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="true" %>
<%@ Register TagPrefix="bdp" Namespace="BasicFrame.WebControls" Assembly="BasicFrame.WebControls.BasicDatePicker" %>
<html>
 <head>
    <title>Basic Date Picker IsDate 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
                Me.BasicDatePicker1.SelectedDate = DateTime.Today
            End If
        End Sub
        
        Sub Selection_Change(sender As Object, e As EventArgs) 
            If Me.BasicDatePicker1.IsDate And Not Me.BasicDatePicker1.IsNull Then
                Response.Write("Valid Date")
            Else 
                Response.Write("Invalid Date")
            End If
        End Sub
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker IsDate 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 IsDate 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)
        {
            if (BasicDatePicker1.IsDate && !BasicDatePicker1.IsNull)
                Response.Write("Valid Date");
            else
                Response.Write("Invalid Date");
        }    
     </script>
 </head>
 <body>
     <form runat="server">
         <h3>Basic Date Picker IsDate 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 | SelectedDate | PostedText