RadDateInput
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:
[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:
Inherited Members
Example:
The following example demonstrates how to dynamically add RadDateInput to the page.
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);
}
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.
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);
}
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
public RadDateInput()
Fields
protected string invalidDateString
protected bool invalidDateStringFlag
Properties
Gets or sets the accessible label for the date input element (aria-label attribute).
public string AriaLabel { get; set; }
Gets or sets the culture used by RadDateInput to format the date.
public CultureInfo Culture { get; set; }
A CultureInfo object that represents the current culture used. The default value is System.Threading.Thread.CurrentThread.CurrentUICulture.
Implements:
Gets or sets the date and time format used by RadDateInput.
[ClientControlProperty]
public virtual string DateFormat { get; set; }
A string specifying the date format used by RadDateInput. The default value is "d" (short date format).
Implements:
Gets or sets the date content of RadDateInput in a database-friendly way.
[Browsable(false)]
[Bindable(true, BindingDirection.TwoWay)]
public object DbSelectedDate { get; set; }
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.
Gets or sets the display date format used by RadDateInput.(Visible when the control is not on focus.)
[ClientControlProperty]
public virtual string DisplayDateFormat { get; set; }
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.
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.
public override string DisplayText { get; set; }
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:
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.
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.
[PersistenceMode(PersistenceMode.InnerProperty)]
public InputIncrementSettings IncrementSettings { get; }
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
[Browsable(false)]
[Bindable(false)]
public string InvalidTextBoxValue { get; }
Used to determine if RadDateInput is empty.
[Browsable(false)]
public bool IsEmpty { get; }
true if the date is empty; otherwise false.
Gets or sets the largest date value allowed by RadDateInput.
[ClientControlProperty]
public DateTime MaxDate { get; set; }
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.
[ClientControlProperty]
public DateTime MinDate { get; set; }
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.
[Obsolete("Use the ClientEvents.OnValueChanged property instead.", false)]
public string OnClientDateChanged { get; set; }
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
Gets or sets the selection on focus options for the RadInput control
[ClientControlProperty]
[Themeable(true)]
public override SelectionOnFocus SelectionOnFocus { get; set; }
A Telerik.WebControls.SelectionOnFocus object that represents the selection on focus in RadInput control. The default value is "None".
- None
- CaretToBeginning
- CaretToEnd
- SelectAll
Overrides:
Use this property to provide selection on focus of RadInput control. You can set one of the following values:
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.
public int ShortYearCenturyEnd { get; set; }
The year when the century ends. Default is 2029.
Implements:
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.
public int ShortYearCenturyStart { get; }
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.
public bool SkipMinMaxDateValidationOnServer { get; set; }
The server-side min/max date validation
protected override HtmlTextWriterTag TagKey { get; }
Overrides:
Methods
Clears the selected date of the RadDateInput control and displays a blank date.
public virtual void Clear()
Code moved into this method from OnPreRender to make sure it executed when the framework skips OnPreRender() for some reason
protected override void ControlPreRender()
Overrides:
protected override void DescribeClientEvents(IScriptDescriptor descriptor)
Overrides:
protected override void DescribeClientProperties(IScriptDescriptor descriptor)
Overrides:
protected override void DescribeComponent(IScriptDescriptor descriptor)
Overrides:
Loads the client state data
protected override void LoadClientState(Dictionary<string, object> clientState)
Overrides:
Executed when post data is loaded from the request
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
Overrides:
protected override void SetDesignTimeAttributes(HtmlTextWriter writer)
Overrides: