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.
false if the PostedText can not be parsed into a valid DateTime object, otherwise true.
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.
[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 id="Form1" 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, System.EventArgs e)
{
// Set SelectedDate to Today
if(!IsPostBack)
BasicDatePicker1.SelectedDate = DateTime.Today;
}
private void Selection_Change(object sender, System.EventArgs e)
{
if(BasicDatePicker1.IsDate && !BasicDatePicker1.IsNull)
Response.Write("Valid Date");
else
Response.Write("Invalid Date");
}
</script>
</head>
<body>
<form id="Form1" 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>
BasicDatePicker Class | BasicFrame.WebControls Namespace | SelectedDate | PostedText