I have this..
<ig:WebDatePicker ID="WebDatePicker1" runat="server" DisplayModeFormat="g" EditModeFormat="g" StyleSetName="Default" StyleSetPath="ig_res"> <ClientSideEvents CalendarClosed="CalClose1" /> </ig:WebDatePicker>
so when the calendarClosed event is hit I want it to run this function.
function CalClose1() if icount1 =0 then icount1=1 webdatepicker1.value = webdatepicker1.value & " 12:00:00 AM" end if end function
I get an error from your javascript saying CalClose1 must be a function..
someone wanna tell me what I have done wrong?
entire script below
<script type="text/script" language="vbscript"> dim icount1 dim icount2 function CalClose1() if icount1 =0 then icount1=1 webdatepicker1.value = webdatepicker1.value & " 12:00:00 AM" end if end function function CalClose2() if icount2 =0 then icount2=1 webdatepicker2.value = webdatepicker2.value & " 11:59:59 PM" end if end function </script>
more to go with this..
I am using the calendar closed client side event to try and get the date, I need to be able to manipulate it. however, it always comes up null first time and last date entered every other time.
How can I get the value selected on the calendar on the client si9de?
Hello,
You should use javascript to get the old and new values in the client side CalendarClosed event. The event is passed two arguments sender (the WebDatePicker Control) & eventArgs. From the eventArgs you can get the old and new values:
function CalendarClosed(sender, eventArgs){ ///<summary> /// ///</summary> ///<param name="sender" type="Infragistics.Web.UI.WebDatePicker"></param> ///<param name="eventArgs" type="Infragistics.Web.UI.TextEditorValueChangingEventArgs"></param>
var old_val = eventArgs.get_oldValue(); var new_val = eventArgs.get_value();
....
}
Thanks,
Valerie
ah.. thank you very much..
that is working just dandy.
okay, so I can now get the value. I am trying to set the value but it is not working.
dropdown calendar, select any day, returns m/d/y 12:00 AM
I want it to return m/d/y 00:01 AM
My code is below..
the other thing is this should only do this 1 time, hence the boolean compare
var dp1 = new Boolean(); function dp1_ft(sender, eventArgs) { if (dp1 == false) { dp1 = true; var dp = $find("<%=WebDatePicker1.ClientID%>"); if (!dp) { return; } else { var new_val = eventArgs.get_value(); var replacementDate = new Date() replacementDate = (new_val.getMonth() + 1) + '/' + new_val.getDate() + '/' + new_val.getFullYear() + ' 00:01 AM'; alert('newvalue=' + replacementDate); dp.set_text(replacementDate); dp.set_value(replacementDate); alert(' newvalue=' + dp.get_value()); } } }
so here is the complete function..
function dp1_ft(sender, eventArgs) { if (dp1 == false) { dp1 = true; var dp = $find("<%=WebDatePicker1.ClientID%>"); if (!dp) { return; } else { var new_val = eventArgs.get_value(); var replacementDate = new Date() replacementDate = (new_val.getMonth() + 1) + '/' + new_val.getDate() + '/' + new_val.getFullYear() + ' 12:01 AM'; // alert('original value=' + new_val); // alert('original text=' + new_val.toLocaleString()); dp.set_text(replacementDate.toLocaleString()); dp.set_value(replacementDate); // alert(' replacement value=' + dp.get_value()); // alert(' replacement text=' + dp.get_text()); } } }
I noticed when the alerts were not commented that the control would show the correct value. but as soon as I would click the okay on the alert box it would go back to what was there. example:
dropdown calendar select November 10
alerts in get_value statements show.. 11/10/2010 12:01 AM
but calendar control still shows 11/10/2010 12:00 AM
I have tried changing the time value to something else like 2AM, but it still doesn't change.
You need to introduce a delay to set the time correctly. For example:
var date_val;
function CalendarClosed(sender, eventArgs) { var dt = eventArgs.get_value(); date_val = dt.format("MM/dd/yyyy") +" 00:01 AM"; setTimeout("UpdateDate()", 500); } function UpdateDate() { if (date_val != null && date_val != "") { var wdp = $find("<%=WebDatePicker1.ClientID %>"); wdp.set_text(date_val); } }
Please let me know if you have any questions.
thanks. that worked.. your date code was much more elgant then mine.. (you can tell I don't do much javascript)