1
votes

How to set max decimal value =.45 I want to select the number of hours... i.e.

1.15 hrs
1.30 hrs
1.45 hrs
2.00 hrs 
'
'
'

and so on

                   <ext:NumberField 
                        ID="numHours" 
                        runat="server" 
                        ColumnWidth="0.2" LabelWidth="50"
                        MinValue="0"
                        MaxValue="12"
                        AllowDecimals="true"
                        DecimalPrecision="2"
                        Step="0.15"
                        />
1

1 Answers

1
votes

Maybe something like this.

<%@ Page Language="C#" %>

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

<!DOCTYPE html>

<html>
<head runat="server">
    <title>Ext.NET v2 Example</title>

    <script>
        var onChange = function (field, newValue, oldValue) {
            if (newValue % 1 > 0.45) {
                if (newValue > oldValue) {
                    newValue += 0.4;
                } else {
                    newValue -= 0.4;
                }
            }

            this.setValue(newValue);
        };
    </script>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager runat="server" />

         <ext:NumberField 
            runat="server" 
            MinValue="0"
            MaxValue="12"
            AllowDecimals="true"
            DecimalPrecision="2"
            TrimTrailedZeros="false"
            Step="0.15">
            <Listeners>
                <Change Fn="onChange" />
            </Listeners>
         </ext:NumberField>
    </form>
</body>
</html>

Though, personally, I would also consider a possibility to use a SpinnerField. Here is an example.