Search code examples
javascriptasp.netcomponentone

Set date for C1WebDateEdit control on page load


I have a webdateedit control. On the page load I want to set a date to that control through javascript. I have tried the following but its not working,

var userid='<%=Session("userid").toString %>';   // 20-Dec-2013
var strdate=dtsheet.split("-");  
var sheetdate =new Date(strdate[2] +"/"+ changemonth(strdate[1]) +"/"+ strdate[0]); //changemonth will give 12
dtpstartdate.setDate(sheetdate.getDate); //it is not working

design:

<c1i:C1WebDateEdit ID="dtpstartdate" runat="server" OnClientdateChanged="javascript:enable(true);" WebCalendar="postartdate" OnDateChanged="dtpstartdate_DateChanged">
</c1i:C1WebDateEdit>

What could be the reason?


Solution

  • I found my own solution. to set date for a c1WebdateEdit control, use the following code

    var strdate=dtsheet.split("-");
    var sheetdate =new Date(strdate[2] +"/"+ strdate[1] +"/"+ strdate[0]);
    <%=dtpstartdate.ClientObjectID%>.set_Value(sheetdate);
    

    to get the date,

    var dt=<%=dtpstartdate.ClientObjectID%>.get_Value();