[CLOSED] DateField IsEmpty always returns false

  1. #1

    [CLOSED] DateField IsEmpty always returns false

    Latest from SVN compares object references when comparing the date and EmptyValue and so always returns false.
    IsNull used to work perfectly however this seems to have been removed.

    simple test:

    <%@ page language="C#" %>
    
    <%@ register assembly="Ext.Net" tagprefix="ext" namespace="Ext.Net" %>
    <script runat="server">
    
      protected override void OnLoad(EventArgs e)
      {
        base.OnLoad(e);
        emptyValue.Text = "empty value: " + dateField.EmptyValue.ToString();
      }
    
      protected void SubmitClick(object sender, EventArgs args)
      {
        result.Text = dateField.IsEmpty ? "empty" : "not empty";
        postedValue.Text = "posted value: " + dateField.SelectedValue.ToString();
      }
      
    </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 runat="server">
      <title></title>
    </head>
    <body>
      <form id="form1" runat="server">
      <div>
        <ext:resourcemanager runat="server" />
        <asp:label id="emptyValue" runat="server" /><br />
        <ext:datefield id="dateField" runat="server" />
        <asp:button id="submit" runat="server" text="Submit" onclick="SubmitClick" /><br />
        <asp:label id="postedValue" runat="server" /><br />
        <asp:label id="result" runat="server" /><br />
      </div>
      </form>
    </body>
    </html>
    Last edited by Daniil; Sep 23, 2010 at 7:19 AM. Reason: [CLOSED]
  2. #2

    NumberField also seems to behave strangely with EmptyValue

    In the example below if I first submit without entering a value IsEmpty is true, and Number = 0
    If I then submit 0, IsEmpty is false and Number = 0 - all ok so far.
    If I then clear the field and submit IsEmpty is true as expected, but Number= -1.79769313486232E+308 - would have expected a consistent result.



    <%@ page language="C#" %>
    
    <%@ register assembly="Ext.Net" tagprefix="ext" namespace="Ext.Net" %>
    <script runat="server">
    
      protected override void OnLoad(EventArgs e)
      {
        base.OnLoad(e);
        emptyValue.Text = "empty value: " + string.Format("{0}", numberField.EmptyValue);
      }
    
      protected void SubmitClick(object sender, EventArgs args)
      {
        result.Text = numberField.IsEmpty ? "empty" : "not empty";
        postedValue.Text = "posted value: " + numberField.Number;
      }
      
    </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 runat="server">
      <title></title>
    </head>
    <body>
      <form id="form1" runat="server">
      <div>
        <ext:resourcemanager runat="server" />
        <asp:label id="emptyValue" runat="server" /><br />
        <ext:numberfield id="numberField" runat="server" />
        <asp:button id="submit" runat="server" text="Submit" onclick="SubmitClick" /><br />
        <asp:label id="postedValue" runat="server" /><br />
        <asp:label id="result" runat="server" /><br />
      </div>
      </form>
    </body>
    </html>
  3. #3
    I've also noticed the change for IsNull to IsEmpty.

    For example, where before I had this:

    if (!extStartDate.IsNull)
    I now find myself having to do things like this:

    if (!extStartDate.IsEmpty && extStartDate.Value != null && (DateTime)extStartDate.Value != DateTime.MinValue)
    (Not fully tested the above yet, as I was searching these forums for more info on the change...)

    The IsNull was quite useful in the past, so wondering if there is an option to have it in again, if possible?

    Thanks!
  4. #4
    Hi brettmas and anup,

    Really it seems there is an issue with IsEmpty. But I'm not sure.

    Here is a sample code demonstrating the issue.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Compare(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Compare?", DateTime.Compare((DateTime)this.DateField1.Value, (DateTime)this.DateField1.EmptyValue) == 0).Show();
        }
    
        protected void IsEmpty(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("IsEmpty?", this.DateField1.IsEmpty).Show();
        }
    </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 runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:DateField ID="DateField1" runat="server"/>
        <ext:Button runat="server" Text="Compare">
            <DirectEvents>
                <Click OnEvent="Compare" />
            </DirectEvents>
        </ext:Button>
        <ext:Button runat="server" Text="IsEmpty">
            <DirectEvents>
                <Click OnEvent="IsEmpty" />
            </DirectEvents>
        </ext:Button>
        </form>
    </body>
    </html>
  5. #5
    Hi,

    Fixed. Now IsEmpty method works correctly. Please update from SVN
  6. #6
    Thanks for that. That seems to have done the trick, for me.
  7. #7
    thanks! that's sorted it out for me.

Similar Threads

  1. Replies: 2
    Last Post: Apr 09, 2012, 2:13 PM
  2. radio button always returns false
    By khadga in forum 1.x Help
    Replies: 4
    Last Post: Nov 20, 2010, 7:37 AM
  3. [CLOSED] #{AjaxMethods} returns null
    By Steve in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 14, 2009, 7:22 AM
  4. [CLOSED] datefield always returns min value
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 30, 2009, 8:22 AM
  5. [CLOSED] dateRenderer returns NaN-NaN-NaN
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 01, 2008, 8:31 AM

Posting Permissions