Oct 02, 2012, 8:39 AM
[CLOSED] NumberField postback error
Hi,
When using a number field if you enter 2 dots as the value (..) it breaks all direct methods and direct events for the page. We can obviously work around this by checking if the formpanels/fields are valid client side but we should be able to catch the error server side!
Example code:
Default.aspx:-
When using a number field if you enter 2 dots as the value (..) it breaks all direct methods and direct events for the page. We can obviously work around this by checking if the formpanels/fields are valid client side but we should be able to catch the error server side!
Example code:
Default.aspx:-
<%@ Page CodeBehind="~/Default.aspx.cs" AutoEventWireup="true" Language="C#" Inherits="ext2testapp.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="resMan" runat="server">
</ext:ResourceManager>
<form id="Form1" runat="server">
<ext:NumberField runat="server" ID="test" />
<ext:Button runat="server" ID="btnTest" Text="click me">
<DirectEvents>
<Click OnEvent="btnClick" />
</DirectEvents>
<Listeners>
<Click Handler="#{DirectMethods}.stuff()" />
</Listeners>
</ext:Button>
</form>
</body>
</html>
Default.aspx.cs:-public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnClick(object sender, DirectEventArgs e)
{
var num = test.Value;
}
[DirectMethod]
public void stuff()
{
var num = test.Value;
}
}
the error throws in numberfieldbase in the checkrange function (via LoadPostData), it hits Double.Parse("..", nf) and then hits the catch which throws an error, but on postback we cant catch it, instead wouldn't it be better to mark the field as invalid server side and set the value to its empty value so it doesn't break eveything on a postback?
Last edited by Daniil; Oct 12, 2012 at 6:09 AM.
Reason: [CLOSED]