[CLOSED] Setting TimeField.Value to null or EmptyValue throws exception from DirectMethod

  1. #1

    [CLOSED] Setting TimeField.Value to null or EmptyValue throws exception from DirectMethod

    When setting a TimeField's Value to null, "", or EmptyValue from a DirectMethod or DirectEvent, an exception is thrown when the class tries to update the display. The TimeField class tries to construct a new DateTime object using "time.Ticks", which is "long.MinValue" by default. This causes the DateTime constructor to throw an ArgumentOutOfRangeException.

    Reproduction:

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Button1_Click(object sender, EventArgs e)
        {
            TimeField1.Value = null;
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
        <ext:TimeField runat="server" ID="TimeField1"/>
         
        <ext:Button ID="Button1" runat="server" Text="Submit">
            <DirectEvents>
                <Click OnEvent="Button1_Click" />
            </DirectEvents>
        </ext:Button>
    </body>
    </html>
    Relevant method in Ext.Net.TimeField.cs:

        internal void SetSelectedTime(TimeSpan time)
        {
          CultureInfo culture = this.SafeResourceManager != null ? this.ResourceManager.CurrentLocale : CultureInfo.CurrentUICulture;
          this.Call("setValue", new object[1]
          {
            (object) new DateTime(time.Ticks).ToString(this.Format, (IFormatProvider) culture).ToLower(culture)
          });
        }
    Last edited by Daniil; Jan 13, 2012 at 5:43 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please don't use Value directly.

    To clear TimeField, please use its Clear method.
    TimeField1.Clear();
    You might be also interested in the Reset method.
    http://docs.sencha.com/ext-js/3-4/#!...d-method-reset
  3. #3
    Thanks for the advice, that works as expected!

Similar Threads

  1. [CLOSED] Adding panels to a tab panel throws exception
    By RCM in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 09, 2012, 6:28 PM
  2. Replies: 4
    Last Post: Sep 14, 2011, 8:01 PM
  3. Replies: 1
    Last Post: Jun 08, 2010, 11:38 AM
  4. Paging and Sorting Example throws exception
    By Skorfulose in forum 1.x Help
    Replies: 1
    Last Post: Nov 19, 2009, 3:30 AM
  5. Replies: 2
    Last Post: Apr 01, 2009, 7:02 AM

Tags for this Thread

Posting Permissions