c# - TryParseExact() method not parsing dates selected from jQuery's datepicker -


i using jquery's datepicker widget in following way(in master page) :

<script>    $(".datepicker").datepicker({                     showanim: 'fadein',                     mindate: 0,                     maxdate: "3m",                     dateformat: "dd-mm-yy"                                     });  </script> 

i have asp:repeater control in content page.in c# code(of content page), using datetime.tryparseexact method date repeater control , parse , in following way :

for (int = 0; < rptr.items.count; i++)  { .... ...//find other controls ...       textbox txtdate = (textbox)rptr.items[i].findcontrol("txtservicedate");     datetime eventdate = new datetime();              if (txtdate.text != null)             {                 if (datetime.tryparseexact(txtdate.text, "dd-mm-yy", null, system.globalization.datetimestyles.none, out eventdate))                 {                     cartobj.servicedate = eventdate; //code doesn't go here                 }                 else                 {                     cartobj.servicedate = datetime.now; //code reaches here!which means parsing failed                 }             }             else             {                 cartobj.servicedate = datetime.now;             } ... ....  ...//other code } 

as can see in datepicker(), have specified date-format dd-mm-yy', date doesn't formatted in mytrparseexact()` method though formats sepcified same.

what possibly wrong ?

edit: have added screenshot of goes tryparseexact method in debug mode :

enter image description here

you trying format date follows:

dd-mm-yy

[day]-[minute]-[year]

in .net, months represented mm.

you can find full reference string representations of dates here https://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -