The Eclipse Web Solutions ASP.NET DatePicker control combines a textbox and a calendar, to support both novice and power users. If the user expans the calendar it displays on a higher layer, so it does not affect the layout of the page. When developing enterprise ASP.NET applications it is common to require the input of dates. The DatePicker allows the end user to select a date from a calendar or by inputting the data directly. It supports custom templates for 'month' view, configurable options for minimum and maximum date, start view and the depth of the navigation.
-->This topic describes the styles and templates for the DatePicker control. You can modify the default ControlTemplate to give the control a unique appearance. For more information, see Customizing the Appearance of an Existing Control by Creating a ControlTemplate.
DatePicker Parts
The following table lists the named parts for the DatePicker control.
Part | Type | Description |
---|---|---|
PART_Root | Grid | The root of the control. |
PART_Button | Button | The button that opens and closes the Calendar. |
PART_TextBox | DatePickerTextBox | The text box that allows you to input a date. |
PART_Popup | Popup | The popup for the DatePicker control. |
DatePicker States
The following table lists the visual states for the DatePicker control.
VisualState Name | VisualStateGroup Name | Description |
---|---|---|
Normal | CommonStates | The default state. |
Disabled | CommonStates | The DatePicker is disabled. |
Valid | ValidationStates | The control uses the Validation class and the HasError attached property is false . |
InvalidFocused | ValidationStates | The HasError attached property is true has the control has focus. |
InvalidUnfocused | ValidationStates | The HasError attached property is true has the control does not have focus. |
DatePickerTextBox Parts
The following table lists the named parts for the DatePickerTextBox control.
Part | Type | Description |
---|---|---|
PART_Watermark | ContentControl | The element that contains the initial text in the DatePicker. |
PART_ContentElement | FrameworkElement | A visual element that can contain a FrameworkElement. The text of the TextBox is displayed in this element. |
DatePickerTextBox States
The following table lists the visual states for the DatePickerTextBox control.
VisualState Name | VisualStateGroup Name | Description |
---|---|---|
Normal | CommonStates | The default state. |
Disabled | CommonStates | The DatePickerTextBox is disabled. |
MouseOver | CommonStates | The mouse pointer is positioned over the DatePickerTextBox. |
ReadOnly | CommonStates | The user cannot change the text in the DatePickerTextBox. |
Focused | FocusStates | The control has focus. |
Unfocused | FocusStates | The control does not have focus. |
Watermarked | WatermarkStates | The control displays its initial text. The DatePickerTextBox is in the state when the user has not entered text or selected a date. |
Unwatermarked | WatermarkStates | The user has entered text into the DatePickerTextBox or selected a date in the DatePicker. |
Valid | ValidationStates | The control uses the Validation class and the HasError attached property is false . |
InvalidFocused | ValidationStates | The HasError attached property is true and the control has focus. |
InvalidUnfocused | ValidationStates | The HasError attached property is true and the control does not have focus. |
DatePicker ControlTemplate Example
The following example shows how to define a ControlTemplate for the DatePicker control.
The preceding example uses one or more of the following resources.
For the complete sample, see Styling with ControlTemplates Sample.
See also
is there any good free/open source time picker control that goes well with ASP.NET Calendar control?
djot2,72733 gold badges1515 silver badges2626 bronze badges
SoftwareGeekSoftwareGeek6,8691616 gold badges5555 silver badges7777 bronze badges
9 Answers
JQuery has the best datepicker IMHO. While it's not specific to .Net is still works great.
HTML:
In head element:
Simple as that!
Chuck ConwayChuck Conway13.6k1010 gold badges5050 silver badges9595 bronze badges
The answer to your question is Yes, there is any good free/open source time picker control that goes well with ASP.NET Calendar control.
ASP.NET Calendar control just writes an html table.
If you are using HTML5 and DOT.NET Framework 4.5, then you can use ASP.NET TextBox control instead, and set the TextMode property to either 'Date', or 'Month', or 'Week', or 'Time' or 'DateTimeLocal' or if you are not using either Chrome or Firefox or Internet Explorer, then you also can set this property to 'DateTime'.
Then read the Text property to get the date, or time, or month, or week as string from the TextBox.
If you are using DOT.NET Framework 4.0 or older version, then you can use either html5 input type='date' or input type='month' or input type='week' or input type='time' or input type='datetime-local' or if you are not using either Chrome or Firefox or Internet Explorer, then you also can use input type='datetime'.
If you need on the server side code (written in either C# or Visual Basic) the information that the user input in the date field, then you can try to run this element on server by writing inside the input tag
runat='server'
Also give this element an id, so you can access it on the server side code.Read the Value property to get the input date, time, month, or week as string. If you cannot run this element on the server, then you need an hidden field in addition to the input type='date' or 'time' or 'month' or 'week'.In the submit function (written in javascript) set the value of the hidden field to the value of the input type='date', or 'time', or 'month', or 'week', and then on the server side code, read the Value property of that hidden field as string too.
Sure that the hidden field element of the html can run on the server.
Hope that helps.
user2133061
Since it's the only one I've used, I would suggest the CalendarExtender from http://www.ajaxcontroltoolkit.com/
sshowsshow6,37833 gold badges3737 silver badges6262 bronze badges
In the textbox add this:
It gives you nice looking Datepicker like this:
Other variations of this are:
It gives you this look:
EhsanEhsan
This is solution without jquery.
Add Calendar and TextBox in WebForm -> Source of WebForm has this:
Create methods in cs file of WebForm:
Method DateChange is connected with Calendar event SelectionChanged. It looks like this:DatePicker Image
Bojan JovanovicBojan Jovanovic
This is the free version of their flagship product, but it contains a date and time picker native for asp.net.
recursiverecursive63.7k2222 gold badges122122 silver badges211211 bronze badges
Try bootstrap-datepicker if you are using bootstrap.
rockXrockrockXrock3,05211 gold badge2121 silver badges1818 bronze badges
There is an easy, out of the box implementation: the HTML 5
input type='date'
and the other date-related input types.Okay, you can't style the controls that much and it doesn't work on every browser, but still it can be a very good option in the long term if all modern browsers support it and don't want to include heavy libraries that don't always work that good on mobile devices.
Patrick HofmanPatrick Hofman131k1818 gold badges184184 silver badges242242 bronze badges
If you would like to work with a textbox, be aware that setting the TextMode property to 'Date' will not work on Internet Explorer 11, because it does not currently support the 'Date', 'DateTime', nor 'Time' values.
This example illustrates how to implement it using a textbox, including validation of the dates (since the user could enter just numbers). It will work on Internet Explorer 11 as well other web browsers.
José LugoJosé Lugo