hi! everyone.

please help i need to add a date picker to an asp page and i have been looking over the internet and i cant find anything to help may be a drop down or may be like (check this page http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Calendar/Calendar.aspx) .it would be real nice if you could provide me with the code.

please help...

than you.

Dani AI

Generated

Several straightforward ways exist to add a date picker to an ASP.NET page. 's AjaxControlToolkit suggestion is a valid WebForms-native choice (good if you want a server-side control). 's roundup is useful for exploring alternatives. For most modern projects the easiest options are:

  • HTML5 input[type=date] (use TextMode="Date" on an ASP.NET TextBox) when browser support is acceptable.
  • jQuery UI Datepicker for broad desktop-browser support and easy customization.
  • A lightweight modern picker (flatpickr, Pikaday) for better mobile behavior and smaller footprint.

Quick example: attach jQuery UI Datepicker to an ASP.NET TextBox and reinitialize after UpdatePanel partial postbacks.

<asp:TextBox ID="txtDate" runat="server" />

<script>
function initDatepicker() {
  $("#<%= txtDate.ClientID %>").datepicker({ dateFormat: 'yy-mm-dd' });
}
$(initDatepicker);
if (typeof Sys !== 'undefined') {
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(initDatepicker);
}
</script>

Practical notes and troubleshooting:

  • Include jQuery, jQuery UI JS and the UI CSS before the init script. If the picker never appears check the browser console for missing files.
  • Use dateFormat: 'yy-mm-dd' to emit an ISO-like string that's easy to parse server-side (use DateTime.ParseExact or InvariantCulture).
  • HTML5 input[type=date] looks native on mobile but is inconsistent across desktop browsers — provide a JS fallback for older clients.
  • If the picker opens behind modals, try appendTo: 'body' or adjust z-index.
  • For localization set the datepicker regional settings or handle parsing explicitly on the server.

jQuery UI Datepicker docs: https://jqueryui.com/datepicker/
HTML5 date input info: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date

Recommended Answers

All 2 Replies

quite a few options here:

To insert DatePicker in aspx page use following code.

<asp:ScriptManager></asp:ScriptManager>
<ajaxToolkit:Calendar runat="server"
    TargetControlID="Date1"
    CssClass="ClassName"
    Format="MMMM d, yyyy"
    PopupButtonID="Image1" />

Here TargetControlId is the textbox name where you would like to inset date.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.