New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

A control which ensures the date entered by the user is verified and accurate.

You need to set the DateFormat to specify the relevant format for the date. You can also specify the culture information by setting the Culture.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
[ClientScriptResource("Telerik.Web.UI.RadDateInput", "Telerik.Web.UI.Input.DateInput.RadDateInputScript.js")]
[RequiredScript(typeof(RadTextBox))]
[ValidationProperty("Text")]
[ControlValueProperty("SelectedDate")]
[ToolboxBitmap(typeof(RadDateInput), "Toolbox.Icons.DateInput.png")]
[TelerikToolboxCategory("Data Editing")]
public class RadDateInput : RadInputControl, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IScriptControl, IControlResolver, IPostBackDataHandler, ISkinnableControl, IControl, IPostBackEventHandler, INamingContainer, IEditableTextControl, ITextControl, ICustomTypeDescriptor, IRadDateInput

Inheritance: objectControlWebControlRadWebControlRadInputControlRadDateInput...

Implements: IAttributeAccessorIComponentIControlIControlBuilderAccessorIControlDesignerAccessorIControlResolverICustomTypeDescriptorIDataBindingsAccessorIDisposableIEditableTextControlIExpressionsAccessorINamingContainerIParserAccessorIPostBackDataHandlerIPostBackEventHandlerIRadDateInputIScriptControlISkinnableControlITextControlIUrlResolutionService...

Inherited Members RadInputControl.setWidthRadInputControl.setHeightRadInputControl.setStyleRadInputControl.OnChildrenCreated()RadInputControl.isOnlyInputRendered()RadInputControl.shouldRenderWhiteSpace()RadInputControl.IsMultiLine()RadInputControl.AddAttributesToRender(HtmlTextWriter)RadInputControl.ApplyCurrentCssClass(HtmlTextWriter)RadInputControl.Focus()RadInputControl.SetStyleClasses()RadInputControl.StylesToClient()RadInputControl.FormatCssClass(string, string)RadInputControl.SetDefaultSize()RadInputControl.MergeStyles()RadInputControl.MergeAuxiliaryStyles()RadInputControl.OnTextChanged(EventArgs)RadInputControl.CalculateWrapperWidth()RadInputControl.CalculateInputWidth()RadInputControl.RenderBeginTagSingleInput(HtmlTextWriter)RadInputControl.RenderBrowserSpecificStyles(HtmlTextWriter)RadInputControl.RenderContentsSingleInputFields(HtmlTextWriter)RadInputControl.RenderInnerWrapperContent(HtmlTextWriter)RadInputControl.RenderContentsSingleInput(HtmlTextWriter)RadInputControl.RenderContents(HtmlTextWriter)RadInputControl.RenderTextAreaContents(HtmlTextWriter)RadInputControl.RenderPasswordStrengthIndicator(HtmlTextWriter, bool)RadInputControl.GetOffsetAdditionalClasses()RadInputControl.RenderChildren(HtmlTextWriter)RadInputControl.RenderLabel(HtmlTextWriter, string)RadInputControl.DescribeValueAndTextProperties(IScriptDescriptor)RadInputControl.GetPostBackEventReference()RadInputControl.CreateChildControls()RadInputControl.RaisePostDataChangedEvent()RadInputControl.RegisterScriptControl()RadInputControl.LoadViewState(object)RadInputControl.SaveViewState()RadInputControl.TrackViewState()RadInputControl.EnableSingleInputRenderingRadInputControl.LabelRadInputControl.TagNameRadInputControl.LabelCssClassRadInputControl.AutoPostBackRadInputControl.AutoCompleteTypeRadInputControl.TextElementIDRadInputControl.CausesValidationRadInputControl.MaxLengthRadInputControl.ReadOnlyRadInputControl.EmptyMessageRadInputControl.InvalidStyleDurationRadInputControl.BrowserRadInputControl.ClientEventsRadInputControl.ShowButtonRadInputControl.ButtonsPositionRadInputControl.ButtonCssClassRadInputControl.WrapperCssClassRadInputControl.ValidationTextRadInputControl.ValidationGroupRadInputControl.DisplayRadInputControl.EnableAriaSupportRadInputControl.EmptyMessageStyleRadInputControl.ReadOnlyStyleRadInputControl.FocusedStyleRadInputControl.DisabledStyleRadInputControl.InvalidStyleRadInputControl.InvalidRadInputControl.HoveredStyleRadInputControl.EnabledStyleRadInputControl.WidthRadInputControl.LabelWidthRadInputControl.EnableOldBoxModelRadInputControl.ShouldResetWidthInPixelsRadInputControl.HeightRadInputControl.AccessKeyRadInputControl.BackColorRadInputControl.BorderColorRadInputControl.BorderStyleRadInputControl.BorderWidthRadInputControl.CssClassRadInputControl.EnableAjaxSkinRenderingRadInputControl.EnabledRadInputControl.EnableEmbeddedBaseStylesheetRadInputControl.EnableEmbeddedScriptsRadInputControl.EnableEmbeddedSkinsRadInputControl.VisibleRadInputControl.ToolTipRadInputControl.EnableThemingRadInputControl.EnableViewStateRadInputControl.TabIndexRadInputControl.SkinRadInputControl.SkinIDRadInputControl.SupportsRenderingModeRadInputControl.EmptySkinRadInputControl.ResizableRadInputControl.defaultWidthRadInputControl.ButtonContainerRadInputControl.ButtonsLightContainerRadInputControl.LastSetTextBoxValueRadInputControl.ChildrenCreatedRadInputControl.TextChangedWebControl.ApplyStyle(Style)WebControl.CopyBaseAttributes(WebControl)WebControl.CreateControlStyle()WebControl.MergeStyle(Style)WebControl.Render(HtmlTextWriter)WebControl.RenderBeginTag(HtmlTextWriter)WebControl.RenderEndTag(HtmlTextWriter)WebControl.AttributesWebControl.ControlStyleWebControl.ControlStyleCreatedWebControl.DisabledCssClassWebControl.StyleWebControl.FontWebControl.ForeColorWebControl.HasAttributesWebControl.IsEnabledWebControl.SupportsDisabledAttributeControl.ResolveAdapter()Control.HasEvents()Control.GetRouteUrl(object)Control.GetRouteUrl(string, object)Control.GetRouteUrl(RouteValueDictionary)Control.GetRouteUrl(string, RouteValueDictionary)Control.GetUniqueIDRelativeTo(Control)Control.ApplyStyleSheetSkin(Page)Control.OnDataBinding(EventArgs)Control.DataBind()Control.DataBind(bool)Control.DataBindChildren()Control.AddParsedSubObject(object)Control.EnsureID()Control.OnInit(EventArgs)Control.ClearChildState()Control.ClearChildControlState()Control.ClearChildViewState()Control.ClearEffectiveClientIDMode()Control.ClearCachedClientID()Control.LoadControlState(object)Control.MapPathSecure(string)Control.OpenFile(string)Control.OnLoad(EventArgs)Control.OnPreRender(EventArgs)Control.BuildProfileTree(string, bool)Control.SaveControlState()Control.RenderControl(HtmlTextWriter)Control.RenderControl(HtmlTextWriter, ControlAdapter)Control.OnUnload(EventArgs)Control.Dispose()Control.RaiseBubbleEvent(object, EventArgs)Control.OnBubbleEvent(object, EventArgs)Control.AddedControl(Control, int)Control.CreateControlCollection()Control.ResolveUrl(string)Control.ResolveClientUrl(string)Control.FindControl(string)Control.FindControl(string, int)Control.GetDesignModeState()Control.HasControls()Control.IsLiteralContent()Control.EnsureChildControls()Control.RemovedControl(Control)Control.SetDesignModeState(IDictionary)Control.SetRenderMethodDelegate(RenderMethod)Control.ClientIDModeControl.ClientIDControl.ClientIDSeparatorControl.ContextControl.AdapterControl.DesignModeControl.EventsControl.IDControl.IsChildControlStateClearedControl.ViewStateModeControl.IsViewStateEnabledControl.NamingContainerControl.IdSeparatorControl.LoadViewStateByIDControl.PageControl.RenderingCompatibilityControl.TemplateControlControl.ParentControl.TemplateSourceDirectoryControl.AppRelativeTemplateSourceDirectoryControl.SiteControl.UniqueIDControl.HasChildViewStateControl.ControlsControl.ValidateRequestModeControl.ViewStateControl.ViewStateIgnoresCaseControl.ChildControlsCreatedControl.IsTrackingViewStateControl.DisposedControl.DataBindingControl.InitControl.LoadControl.PreRenderControl.Unloadobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Example:

The following example demonstrates how to dynamically add RadDateInput to the page.

csharp
private void Page_Load(object sender, System.EventArgs e)
{
    RadDateInput dateInput = new RadDateInput();
    dateInput.ID = "dateInput";
    dateInput.Format = "d"; //Short date format
    dateInput.Culture = new CultureInfo("en-US");
    dateInput.SelectedDate = DateTime.Now;

    DateInputPlaceholder.Controls.Add(dateInput);
}
csharp
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim dateInput As New RadDateInput()
    dateInput.ID = "dateInput"
    dateInput.Format = "d" 'Short Date Format
    dateInput.Culture = New CultureInfo("en-US")
    dateInput.SelectedDate = DateTime.Now

    DateInputPlaceholder.Controls.Add(dateInput)
End Sub

RadDateInput to the page.

csharp
private void Page_Load(object sender, System.EventArgs e)
{
    RadDateInput dateInput = new RadDateInput();
    dateInput.ID = "dateInput";
    dateInput.Format = "d"; //Short date format
    dateInput.Culture = new CultureInfo("en-US");
    dateInput.SelectedDate = DateTime.Now;

    DateInputPlaceholder.Controls.Add(dateInput);
}
csharp
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim dateInput As New RadDateInput()
    dateInput.ID = "dateInput"
    dateInput.Format = "d" 'Short Date Format
    dateInput.Culture = New CultureInfo("en-US")
    dateInput.SelectedDate = DateTime.Now

    DateInputPlaceholder.Controls.Add(dateInput)
End Sub

Constructors

C#
public RadDateInput()

Fields

C#
protected string invalidDateString
C#
protected bool invalidDateStringFlag

Properties

Gets or sets the accessible label for the date input element (aria-label attribute).

C#
public string AriaLabel { get; set; }

Gets or sets the culture used by RadDateInput to format the date.

C#
public CultureInfo Culture { get; set; }
Property Value:

A CultureInfo object that represents the current culture used. The default value is System.Threading.Thread.CurrentThread.CurrentUICulture.

Implements: IRadDateInput.Culture

Example:
cs-api-definition
private void Page_Load(object sender, System.EventArgs e)
{
RadDateInput1.Culture = new CultureInfo("en-US");
}

Gets or sets the date and time format used by RadDateInput.

C#
[ClientControlProperty]
public virtual string DateFormat { get; set; }
Property Value:

A string specifying the date format used by RadDateInput. The default value is "d" (short date format).

Implements: IRadDateInput.DateFormat

Example:
cs-api-definition
private void Page_Load(object sender, System.EventArgs e)
{
RadDateInput1.DateFormat = "M/d/yyyy"; //Short date pattern. The same as "d".
}

Gets or sets the date content of RadDateInput in a database-friendly way.

C#
[Browsable(false)]
[Bindable(true, BindingDirection.TwoWay)]
public object DbSelectedDate { get; set; }
Property Value:

A DateTime object that represents the selected date. The default value is MinDate.

This property behaves exactly like the SelectedDate property. The only difference is that it will not throw an exception if the new value is null or DBNull. Setting a null value will revert the selected date to the MinDate value.

Example:
cs-api-definition
private void Page_Load(object sender, System.EventArgs e)
{
RadDateInput1.DbSelectedDate = tableRow["BirthDate"];
}

Gets or sets the display date format used by RadDateInput.(Visible when the control is not on focus.)

C#
[ClientControlProperty]
public virtual string DisplayDateFormat { get; set; }
Property Value:

A string specifying the display date format used by RadDateInput. The default value is "d" (short date format). If the DisplayDateFormat is left blank, the DateFormat will be used both for editing and display.

You can examine DateTimeFormatInfo class for a list of all available format characters and patterns.

Example:
cs-api-definition
private void Page_Load(object sender, System.EventArgs e)
{
RadDateInput1.DisplayDateFormat = "M/d/yyyy"; //Short date pattern. The same as "d".
}

Gets or sets the display text which allows you to set the display value from the Server to a different value the actual value. Similar to the empty message, but shown even if the input is not empty. This text will be cleared once the user changes the input value.

C#
public override string DisplayText { get; set; }
Property Value:

The display text which allows you to set the display value from the Server to a different value the actual value. Similar to the empty message, but shown even if the input is not empty. This text will be cleared once the user changes the input value.

Overrides: RadInputControl.DisplayText

Toggles the smart date parsing. Default value is true. When disabled, the developer need to follow the datetime format carefully otherwise the control will display a warning message.

C#
public bool EnableSmartParsing { get; set; }

Gets the settings associated with RadInputControl increment settings determining the behavior when using the mouse wheel and keyboard arrow keys.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public InputIncrementSettings IncrementSettings { get; }
Property Value:

The settings associated with RadInputControl increment settings determining the behavior when using the mouse wheel and keyboard arrow keys.

Gets the invalid date string in the control's textbox

C#
[Browsable(false)]
[Bindable(false)]
public string InvalidTextBoxValue { get; }

Used to determine if RadDateInput is empty.

C#
[Browsable(false)]
public bool IsEmpty { get; }
Property Value:

true if the date is empty; otherwise false.

Gets or sets the largest date value allowed by RadDateInput.

C#
[ClientControlProperty]
public DateTime MaxDate { get; set; }
Property Value:

A DateTime object that represents the largest date value allowed by RadDateInput. The default value is 12/31/2099.

Gets or sets the smallest date value allowed by RadDateInput.

C#
[ClientControlProperty]
public DateTime MinDate { get; set; }
Property Value:

A DateTime object that represents the smallest date value by RadDateInput. The default value is 1/1/1980.

Gets or sets the JavaScript event handler fired whenever the date of RadDateInput changes.

C#
[Obsolete("Use the ClientEvents.OnValueChanged property instead.", false)]
public string OnClientDateChanged { get; set; }
Property Value:

A string specifying the name of the JavaScript event handling routine. The default value is empty string ("").

The event handler function is called with 2 parameters:

  • A reference to the RadDateInput object, which triggered the event;
  • An event arguments object that contains the following properties:
    • OldDate - The old date of the RadDateInput
    • NewDate - The new date of the RadDateInput
Example:
C#
<script type="text/javascript&quot>
function onDateChange(dateInput, args)
{
alert("New date:" + args.NewDate);
}
</script>


<radI:RadDateInput
ID="RadDateInput1"
runat="server"
OnClientDateChanged="onDateChange">
</radI:RadDateInput>

Gets or sets the date content of RadDateInput.

C#
[Browsable(true)]
[Bindable(true, BindingDirection.TwoWay)]
public virtual DateTime? SelectedDate { get; set; }
Property Value:

A DateTime object that represents the selected date. The default value is MinDate.

Example:
cs-api-definition
private void Page_Load(object sender, System.EventArgs e)
{
RadDateInput1.SelectedDate = DateTime.Now;
}

Gets or sets the selection on focus options for the RadInput control

C#
[ClientControlProperty]
[Themeable(true)]
public override SelectionOnFocus SelectionOnFocus { get; set; }
Property Value:

A Telerik.WebControls.SelectionOnFocus object that represents the selection on focus in RadInput control. The default value is "None".

  • None
  • CaretToBeginning
  • CaretToEnd
  • SelectAll

Overrides: RadInputControl.SelectionOnFocus

Use this property to provide selection on focus of RadInput control. You can set one of the following values:

Example:
C#
</%@ Page Language="C#" /%>

</%@ Register Assembly="RadInput.Net2" Namespace="Telerik.WebControls" TagPrefix="radI" /%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">

<title>RadTextBox selection</title>
<script runat="server">

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{

if (DropDownList1.SelectedValue == "CaretToBeginning")
{

this.RadTextBox1.SelectionOnFocus = Telerik.WebControls.SelectionOnFocus.CaretToBeginning;

}
else if (DropDownList1.SelectedValue == "CaretToEnd")
{

this.RadTextBox1.SelectionOnFocus = Telerik.WebControls.SelectionOnFocus.CaretToEnd;

}
else if (DropDownList1.SelectedValue == "SelectAll")
{

this.RadTextBox1.SelectionOnFocus = Telerik.WebControls.SelectionOnFocus.SelectAll;

}
}
</script>
</head>
<body>

<form id="form1" runat="server">
<div>

<radI:RadTextBox SelectionOnFocus="CaretToBeginning" ID="RadTextBox1" runat="server"></radI:RadTextBox>

<br />

<asp:DropDownList AutoPostBack="true" ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">

<asp:ListItem Text="CaretToBeginning">CaretToBeginning</asp:ListItem>

<asp:ListItem Text="CaretToEnd">CaretToEnd</asp:ListItem>

<asp:ListItem Text="SelectAll">SelectAll</asp:ListItem>

</asp:DropDownList></div>
</form>
</body>
</html>

Gets or sets a value that indicates the end of the century that is used to interpret the year value when a short year (single-digit or two-digit year) is entered in the input.

C#
public int ShortYearCenturyEnd { get; set; }
Property Value:

The year when the century ends. Default is 2029.

Implements: IRadDateInput.ShortYearCenturyEnd

Having a value of 2029 indicates that a short year will be interpreted as a year between 1930 and 2029. For example 55 will be interpreted as 1955 but 12 -- as 2012

Gets a value that indicates the start of the century that is used to interpret the year value when a short year (single-digit or two-digit year) is entered in the input.

C#
public int ShortYearCenturyStart { get; }
Property Value:

The year when the century starts. Default is 2029.

Having a value of 2029 indicates that a short year will be interpreted as a year between 1930 and 2029. For example 55 will be interpreted as 1955 but 12 -- as 2012

Gets or sets if the server-side min/max date validation.

C#
public bool SkipMinMaxDateValidationOnServer { get; set; }
Property Value:

The server-side min/max date validation

C#
protected override HtmlTextWriterTag TagKey { get; }

Overrides: RadInputControl.TagKey

Gets or sets the text content of a control.

C#
[Browsable(false)]
[Bindable(false)]
public override string Text { get; set; }
Property Value:

The text content of a control.

Overrides: RadInputControl.Text

Methods

Clears the selected date of the RadDateInput control and displays a blank date.

C#
public virtual void Clear()

Code moved into this method from OnPreRender to make sure it executed when the framework skips OnPreRender() for some reason

C#
protected override void ControlPreRender()

Overrides: RadInputControl.ControlPreRender()

C#
protected override void DescribeClientEvents(IScriptDescriptor descriptor)
Parameters:descriptorIScriptDescriptor

Overrides: RadInputControl.DescribeClientEvents(IScriptDescriptor)

C#
protected override void DescribeClientProperties(IScriptDescriptor descriptor)
Parameters:descriptorIScriptDescriptor

Overrides: RadInputControl.DescribeClientProperties(IScriptDescriptor)

C#
protected override void DescribeComponent(IScriptDescriptor descriptor)
Parameters:descriptorIScriptDescriptor

Overrides: RadInputControl.DescribeComponent(IScriptDescriptor)

Loads the client state data

C#
protected override void LoadClientState(Dictionary<string, object> clientState)
Parameters:clientStateDictionary<string, object>

Overrides: RadInputControl.LoadClientState(Dictionary<string, object>)

Executed when post data is loaded from the request

C#
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
Parameters:postDataKeystringpostCollectionNameValueCollectionReturns:

bool

Overrides: RadInputControl.LoadPostData(string, NameValueCollection)

C#
protected virtual string RangeTextProperty(string value)
Parameters:valuestringReturns:

string

C#
protected override void SetDesignTimeAttributes(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

Overrides: RadInputControl.SetDesignTimeAttributes(HtmlTextWriter)