Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 custom validator

Author  Topic 

raghulvarma
Starting Member

21 Posts

Posted - 2008-10-20 : 13:10:30
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?
   

- Advertisement -