如何检查radNumericTextBox值范围的验证?

时间:2014-09-15 05:05:05

标签: c# asp.net telerik

如何检查radNumericTextBox值范围的验证?当我在radNumericTextBox中输入不正确的值时,我想停止插入。当我在radNumericTextBox中输入不正确的值,然后单击btnInsert时,控件将值更改为0并保存。

我的代码是:

 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true" ShowSummary="false" ValidationGroup="oppSub" DisplayMode="List" />
    <div dir="rtl">
        <telerik:RadNumericTextBox ID="txtDiscount" Type="Percent" MinValue="0" MaxValue="100"
            AllowOutOfRangeAutoCorrect="false" ShowSpinButtons="true"
            ValidationGroup="oppSub"
            runat="server">
            <NumberFormat KeepNotRoundedValue="false" DecimalDigits="3" DecimalSeparator="."
                AllowRounding="false"></NumberFormat>
        </telerik:RadNumericTextBox>

        <asp:Button ID="btnInsert" Text="save" runat="server"
            ValidationGroup="oppSub"></asp:Button>
    </div>

1 个答案:

答案 0 :(得分:1)

要验证telerik RadNumericTextBox,您需要一个范围验证器。

<asp:RangeValidator ID="NumericTextBoxRangeValidator" 
                    runat="server" 
                    ControlToValidate="txtDiscount"
                    ErrorMessage="Please enter in a number between 0 and 100." 
                    Display="Dynamic"
                    MaximumValue="100" MinimumValue="0" Type="Decimal">
</asp:RangeValidator>

这将提醒用户他们已输入并且无效日期并提示另一个。

查看工作中验证器的Telerik's example