C# 如何检查radNumericTextBox值范围的有效性?
如何检查radNumericTextBox值范围的有效性?当我在radNumericTextBox中输入不正确的值时,我想停止插入。当我在radNumericTextBox中输入不正确的值并单击BTN插入时,控件将值更改为0并保存 我的代码是:C# 如何检查radNumericTextBox值范围的有效性?,c#,asp.net,telerik,C#,Asp.net,Telerik,如何检查radNumericTextBox值范围的有效性?当我在radNumericTextBox中输入不正确的值时,我想停止插入。当我在radNumericTextBox中输入不正确的值并单击BTN插入时,控件将值更改为0并保存 我的代码是: <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:ValidationSummary ID="Valid
<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>
要验证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>
验证程序工作时的
正常。我在我的页面中设置了这个验证器。但是Type=“percent”无效。为什么?@user3628391Integer
应该是这样的。我错误地把百分比放在了一起。验证程序并不关心文本框中是否有百分比值,它只是希望验证该值。@user3628391您在文本框中输入的是什么类型的数字?您的类型应该与验证器的类型匹配。如果您输入的是2.00
,那么它将失败,因为这是一个双精度
或十进制
。radnumerictextbox的类型是百分比,它的工作方式是正确的。但radNumericTextBox的无效样式无效