问题描述
我有一个显示不同错误消息的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?
推荐答案
EnableClientScript="true"
Display="Dynamic"
[/ edit]
希望有所帮助。
[/edit]
Hope it helps.
这篇关于RangeValidator错误显示并以文本框格式快速消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!