Rubi Begum

Rubi Begum

  • NA
  • 7
  • 5.7k

Error in validating textbox

Jun 14 2012 3:10 AM
For Validating the MinLengthTest for a textbox i used the following coding their is an error showing :"THE NAME 'txtMinLengthTest ' does not exist in the current context.Please resolve my problem where i need to initialize this  'txtMinLengthTest ' 


Thanks in Advance.


private void txtMinLengthTest_Validated(object sender, EventArgs e)
        {
            bool bTest = txtMinLengthTestIsValid();
            if (bTest == true)
            {
                this.errorProvider1.SetError(txtMinLengthTest, "The field must contain a minimum of 7 characters");
            }
            else
            {
                this.errorProvider1.SetError(txtMinLengthTest, " ");
            }


        }
        // Test to see that the textbox contains a minimum number of characters
        private bool txtMinLengthTestIsValid()
        {
            char[] testArr = txtMinLengthTest.Text.ToCharArray();
            bool testBool = false;
            if (testArr.Length < 7)
            {
                testBool = true;
            }
            return testBool;
        }


     }





Answers (5)