PDA

View Full Version : [CLOSED] NumberField MinValue return null value



Aurelio
Mar 22, 2012, 10:51 AM
Hi,
When setting the property MinValue = 0, if the value is 0, the value property returns null..
Here the sample:
1)Click the button enable field, it's setValue = 0
2)Click the button ShowValue, it's not show 0 but the value is null.
So I can not assign a value of 0 which is the minimum value



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ARWebRevolution.WebForm1" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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 v2 Example</title>

</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" >
</ext:ResourceManager>
<ext:FormPanel ID="FormPanel1" runat="server" ButtonAlign="Right" Height="185" Padding="5"
Title="Title" Width="300">
<FieldDefaults LabelWidth="90" />
<FieldDefaults ReadOnly="true" />
<Items>
<ext:NumberField ID="NumberField1" runat="server" MinValue="0" >
</ext:NumberField>
<ext:TextField ID="TextField1" runat="server" >
</ext:TextField>
</Items>
<Buttons>
<ext:Button ID="Button1" runat="server" Icon="Disk" Text="Enable Field">
<Listeners>
<Click Handler="enableField();" />
</Listeners>
</ext:Button>
<ext:Button ID="Button2" runat="server" Icon="Disk" Text="Show Value">
<Listeners>
<Click Handler="showValue();" />
</Listeners>
</ext:Button>
</Buttons>

</ext:FormPanel>

</form>
<script type="text/javascript" >

function enableField() {
App.NumberField1.setReadOnly(false);
App.NumberField1.setValue(0);
}
function showValue() {
Ext.Msg.show({
title: 'Value',
msg: App.NumberField1.getValue(),
buttons: Ext.Msg.OK,
icon: Ext.Msg.QUESTION
});
}

</script>
</body>
</html>

Thanks
Aurelio

Vladimir
Mar 22, 2012, 12:18 PM
Hi,

getValue method of NumberField returns a number
In your case it is 0. Zero means false in 'if' construction in javascript.
'msg' must be a string

Try this method


function showValue() {
var value = App.NumberField1.getValue();
Ext.Msg.show({
title: 'Value',
msg: !Ext.isEmpty(value) ? value.toString() : false,
buttons: Ext.Msg.OK,
icon: Ext.Msg.QUESTION
});
}

Aurelio
Mar 22, 2012, 1:10 PM
Hi, Vladimir...work ok

Thanks
Aurelio