I have a web form that has textboxes and RangeValidator. The validator works and displays but when you tab to another textbox it disappears. Why is that? What setting did I forget?
<asp:RangeValidator ID="RangeValidatorLY1" runat="server"
ControlToValidate="TextBox1" CssClass="style40"
ErrorMessage="20% Difference. Please verify numbers" ForeColor="Red"
Type="Integer" Enabled="True" Display="Dynamic"></asp:RangeValidator>
<asp:TextBox ID="TextBox1" runat="server" Width="180px" AutoPostBack="True"
ontextchanged="TextBox1_TextChanged" CausesValidation="True"
>0</asp:TextBox>
I also have a code behind that formats the value in the textbox.
TextBox1.Text = string.Format("{0:0,0}", double.Parse(TextBox1.Text));
I also have a code behind for the validator.
double txtVal = Convert.ToDouble(TextBoxLY1.Text);
double minVal = (txtVal * 0.8);
double maxVal = (txtVal * 1.2);
RangeValidatorLY1.MinimumValue = minVal.ToString();
RangeValidatorLY1.MaximumValue = maxVal.ToString();
Here is what is in my textbox text change:
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
int w = Convert.ToInt32(TextBox1.Text.Replace(",", ""));
int v = 0;
TextBox2.Text = Convert.ToString(w + v);
RangeValidatorLY1.Validate();
TextBox1.Text = string.Format("{0:0,0}", double.Parse(TextBox1.Text));
TextBox3.Focus();
}