How to set a date/ get a date for Datepicker in codebehind

11,791

Solution 1

<input id="datepicker0" type="text" name="datepickernm"/> 

You can get the value from below code in the codebehind:

String text = Page.Request.Form["datepickernm"]

Solution 2

Use an ASP textbox control:

<asp:textbox runat="server" id="txtDate"/>

<script type="text/javascript">
  $('#<%= txtDate.ClientID %>').datepicker();
</script>

This way you could get and set the value from code behind.

Share:
11,791

Related videos on Youtube

Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I can't manage to set a date and to get a date of Datepicker in code behind(C#) does anyone have informations to give me about this ? thanks in advance!

      <input id="datepicker" value="01/01/2011" type="text"/>
    
    
    
    $(document).ready(function () {
        $("#datepicker").datepicker();
    });
    
  • Admin
    Admin about 12 years
    so this should work to get date in code behind but to set a date ? thank you for your help
  • EaziLuizi
    EaziLuizi about 10 years
    The best solution for complete functionality.. thank you