Hi,
How can I postback when I use the keyboard to change the value in the WebDatePicker? I know how to accomplish this by selecting from the calendar.
Thank you,
Trent
Hi Viktor,
After I select a date, the calendar closes right away so I can't choose another date. Also, if my format in the field is just the date and no time, I don't see the need to keep it in edit mode. I can use the workaround, but maybe there could be a property to postback after calendar closes.
Thanks,
Hi Trent,
Drop-down calendar is just a helper to enter year-month-date fields in pattern displayed in INPUT-field of datepicker. After selection in drop-down calendar edit mode continues and user may type something else (fill possible hour/minute/second fields). User also may select another date from calendar again. Edit mode stops only on lost focus. If at that time the value in editor before focus is not equal to the value after focus, then ValueChanged event is raised.
If in old version the ValueChanged was raised on close drop-down calendar, then that would be a bug (though, I do not remember similar issue).
If application needs to treat selection from calendar as ValueChanged and trigger postback, then as I suggested before, other events can be processed and explicit postback can be triggered. Below is example with CalendarClosed:
<script type="text/javascript">function WebDatePicker1_CalendarClosed(sender, eventArgs) { var oldVal = eventArgs.get_oldValue(), newVal = eventArgs.get_value(); if (newVal && (!oldVal || oldVal.getTime() !== newVal.getTime())) { sender.set_value(newVal); __doPostBack(sender.get_id(), 'ValueChanged'); }}</script><ig:WebDatePicker ID="WebDatePicker1" runat="server"> <ClientSideEvents CalendarClosed="WebDatePicker1_CalendarClosed" /> <AutoPostBackFlags EnterKeyDown="On" ValueChanged="On" /></ig:WebDatePicker>
I'm using v12.1. This is what happens when I set both ValueChanged="On" and EnterKeyDown="On".
1. Enter date by keyboard will postback when I tab out, which is OK.
2. Select a date by calendar DOES NOT postback, until I click somewhere else. This doesn't seem correct. Shouldn't the postback occur after I select the date in the calendar?
Hello tnguyen13,
It seems that the system has rejected my attachment. I am attaching it again for your reference.
Hope this helps.Please let me know if you have any questions.
Is the sample project attached somewhere?