Question

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?

Était-ce utile?

La solution 2

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();

Autres conseils

I suggest you start by looking at the html produced by C1WebDateEdit control. Then find the input which holds the date value. Once you found it change the javascript to set the value of that input.

var userid='<%=Session("userid").toString %>';   // 20-Dec-2013
var strdate=dtsheet.split("-");  
var sheetdate =new Date(strdate[2] +"/"+ changemonth(strdate[1]) +"/"+ strdate[0]); 

document.getElementById('id of generated input here').value = sheetdate;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top