RangeValidator错误显示并以文本框格式快速消失 [英] RangeValidator error displays and disappears quickly with textbox format

查看:66
本文介绍了RangeValidator错误显示并以文本框格式快速消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示不同错误消息的Web表单。我正在使用Range Validator来显示错误消息。当用户输入数字时,错误消息显示得非常快。我将我的属性更改为EnableClientScript = true显示=动态并获得相同的问题。文本框的格式为代码,以便在需要时添加逗号。以下是代码:



I have a web form that displays different error messages. I am using the Range Validator for displaying the error message. When a user enters in a number the error message displays very quickly. I changed my properties to EnableClientScript= true Display= Dynamic and get the same issue. The textbox is formatted with a code to add commas where needed. Here is the code behind:

TextBoxFTUG.Text = string.Format("{0:0,0}", double.Parse(TextBoxFTUG.Text));





以下是文本框的属性:





Here are the properties for the textbox:

<asp:TextBox ID="TextBoxFTUG" runat="server" Width="180px" AutoPostBack="True" 

                    ontextchanged="TextBoxFTUG_TextChanged">0</asp:TextBox>





当用户点击或标签到下一个文本框时,AutoPost Back可以将数据更改为格式。



我还有一个代码,用于计算RangeValidator。





The AutoPost Back is there to change the data to the format when the user clicks or tabs to the next textbox.

I also have a code behind that does calculations for the RangeValidator.

double txtVal6 = Convert.ToDouble(TextBoxLYFTUG.Text);
        double minVal6 = (txtVal * 0.8);
        double maxVal6 = (txtVal * 1.2);
        RangeValidatorLYFTUG.MinimumValue = minVal6.ToString();
        RangeValidatorLYFTUG.MaximumValue = maxVal6.ToString();





当用户点击提交按钮时,显示所有错误应该早先显示。当用户在文本框中输入高出/低于20%的数据时,如何显示错误?



When the user clicks on the submit button all of the errors display that should have displayed earlier. How can I get the error to display when the user enters data that is 20% higher/lower in the textbox?

推荐答案

您好,



您是否看过验证摘要控件?



[edit]

如果添加以下属性,它还有助于验证更加流畅到您的验证器控件:

Hi,

Have you had a look at the Validation Summary control?

[edit]
It will also help the validation appear more fluid if you add the following properties to your validator controls:
EnableClientScript="true"
Display="Dynamic"



[/ edit]





希望有所帮助。


[/edit]


Hope it helps.


这篇关于RangeValidator错误显示并以文本框格式快速消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆