I have developed a custom validator to see if the name is already present in the array, if present then error message is provided.I have a textbox(TextBox1) to enter a name a button (Button1) to validate.The code that i did is as shown below. string[] names = { "Akash", "Ganga", "Sukaoi" };ServerValidateEventArgs svea = new ServerValidateEventArgs("names", true); protected void Button1_Click(object sender, EventArgs e) { ValidateName(TextBox1.Text,svea); }
public void ValidateName(object sender, ServerValidateEventArgs e) { foreach (string a in names) { if (e.Value.Equals(names)) { Response.Write("Name already exists"); } else { e.IsValid = false; } } }
It runs but does not check for validation?any help?