Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a filed StartDate with Jquery datepicker. datepicker is working fine. but when i assign value from code behind, the field is showing nothing.

if i remove "hasDatePicker" class from field, it displays date correctly.

i need to assign date value from DB when perform edit option, also need datepicker on that field.

Regards,
Lalitha
Posted
Comments
[no name] 28-Nov-14 10:09am    
I think its format problem. make the format same.
lalitha19 28-Nov-14 22:34pm    
Here my javascript code:
$(document).ready(function () { $("#ctl00_cpBusinessMasterPagePlaceHolder_txtStartDate").datepicker(); $("#ctl00_cpBusinessMasterPagePlaceHolder_txtStartDate").datepicker("option", "dateFormat", "dd/mm/yy"); });

<asp:TextBox ID="txtStartDate" runat="server" CssClass="text_field1 datepicker">
Code Behind:
txtStartDate.Text = mode == "relist" ? System.DateTime.Now.ToShortDateString() :( job.StartDate!=null? Convert.ToDateTime(job.StartDate.ToString()).ToShortDateString() : ""); –
Sergey Alexandrovich Kryukov 28-Nov-14 11:43am    
All right, you screwed up something, but how can we see where?
—SA

1 solution

I am using the below code. now it is working fine. i can retrieve the value in own format also set value in my own format


$("#ctl00_cpBusinessMasterPagePlaceHolder_txtStartDate").datepicker(); $.datepicker.setDefaults({ dateFormat: "dd/mm/yy" });


Thanks friends, who are all trying to help me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900