Jan 12, 2012, 3:43 AM
[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:
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]