01 December 2013

Validate Text Box

      Today, we discussed about How to validate Text Box with Error Provider in C#.Net? .
    TextBox should enter only integer.
    create one validation event for integer

Here the Code:
protected void textBox1_Validating (object sender,
   System.ComponentModel.CancelEventArgs e)
      int x = Int32.Parse(textBox1.Text);
      errorProvider1.SetError(textBox1, "");
   catch (Exception ex)
      errorProvider1.SetError(textBox1, "Not an integer value.");

Call this event in constructor
this.textBox1.Validating += new

No comments: