Need help to create date picker in c# web forms application

12,329

One of the quickest ways to achieve this is to use a 3rd party client-side datePicker such as that from JQueryUI.

http://jqueryui.com/datepicker/

You will also need JQuery itself: http://jquery.com/download/

You would add textboxes to your document:

<asp:textbox: id="startDate" runat="server" cssclass="datepicker-field"/>

You can then add javascript to state that you would like all textboxes with a particular css class to become datepickers:

<script>
    $(document).ready(function(){
         $('.datepicker-field').datepicker();        
    });
</script>

After your form posts-back you will be able to get the selected date value as a string from startDate.Text

So you will have to parse and validate the value

Share:
12,329
caked bake
Author by

caked bake

Updated on June 27, 2022

Comments

  • caked bake
    caked bake almost 2 years

    i am creating web application with c# web forms. i need two date pickers to select date interval. However i can't find any default datepicker. calendar server control does not suit me because calendar is big and there is no option to resize it. I found a solution to programically add date picker control from system.windows.controls namespace, but my visual studio does not see datepicker class on that namespace. Does anyone know how to solve that situation? any help would be appreciated

  • RobD
    RobD about 10 years
    That's a pleasure caked bake, please accept as answer