문제

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?

도움이 되었습니까?

해결책 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();

다른 팁

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top