Strange behavior of date serialization

  1. #1

    Strange behavior of date serialization


    The example below is reproducible , but just on SOME computer (means not all, so far I found just single problematic.
    Are we doing something wrong with Culture or somth like that?

    <%@ Page Language="C#" %>
    <!DOCTYPE html>
    <script runat="server">
    	public void LoadDate(DateTime date)
    		X.Msg.Alert("", date).Show();
    	function loadDate() {
    		var date = <%= DateField1.ClientID %>.getValue();;;
    <head runat="server">
    <form runat="server">
    	<ext:ResourceManager runat="server" Namespace="" />
    	<ext:DateField runat="server" ID="DateField1" />
    	<ext:Button runat="server" Text="Click" OnClientClick="loadDate()"></ext:Button>
    And now the problem is that on certain computer , the date that comes to the sever is one day less then the on choosen on UI
    I have added couple of screenshots to demonstrate that. Probably something simple overseen, but I do not have an idea what

    Thank youClick image for larger version. 

Name:	datepicker-fiddler.PNG 
Views:	35 
Size:	60.3 KB 
ID:	25511
    Click image for larger version. 

Name:	datepicker1.PNG 
Views:	37 
Size:	6.0 KB 
ID:	25512
  2. #2
    Hello @Ibrohan!

    This is an issue on how a date field is passed to direct method. Please check and subscribe to the thread for issue #1765 - Problem send date direct method. There you'll find more information on what's going on. There are also a couple solutions you could adopt for the time being.

    In general, ways to avoid this issue are to not rely on JavaScript Date and DateTime conversions. Rather, pass the day-month-year or fetch it, in a date format suited for your needs. So as alternatives to what's in the thread linked above would include referencing the field directly from the direct method and pass the date fields as a string representation of the date, or separate integers for year, month and day.

    To reference the component from code behind in direct method, you would replace the code with:

    X.Msg.Alert("", DateField1.SelectedDate).Show();
    And to pass as string or integer you'd need to change the signature of the LoadDate() direct nethod to either public void LoadDate(string dateStamp) or public void LoadDate(int year, int month, int day), then handle the values accordingly.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Store filter strange behavior
    By Zdenek in forum 2.x Help
    Replies: 3
    Last Post: Oct 31, 2014, 12:13 PM
  2. Strange behavior after nuget
    By bovo13 in forum 2.x Help
    Replies: 7
    Last Post: Oct 17, 2013, 1:21 PM
  3. Strange Button DirectEvent Behavior
    By Doug.Morrow in forum 2.x Help
    Replies: 2
    Last Post: Sep 03, 2012, 6:53 PM
  4. Strange behavior of buttons and itextsharp
    By bovo13 in forum 1.x Help
    Replies: 3
    Last Post: Dec 22, 2011, 6:53 AM
  5. Strange behavior with Window control
    By jlattimore in forum 1.x Help
    Replies: 1
    Last Post: May 30, 2011, 11:23 AM

Posting Permissions