Perform validations for the
Registration page using Error Provider.
using System;
using
System.Windows.Forms;
namespace
Reegistration
{
public partial class Registration : Form
{
string[]
arr = new string[34];
string s;
public
Registration()
{
InitializeComponent();
}
private
void tabPage2_Click(object
sender, EventArgs e)
{
}
private
void button1_Click(object
sender, EventArgs e)
{
errorProvider1.Clear();
if
(validate() == 1)
{
toolStripStatusLabel1.Text = "please Correct The Errors";
}
}
public int validate()
{
int
flag = 0;
foreach
(Control c in
this.tabPage1.Controls)
{
if
(c is TextBox)
{
if
(c.Text == "")
errorProvider1.SetError(c, "Field Cannot be Empty");
flag = 1;
}
}
foreach
(Control c in
this.tabPage2.Controls)
{
if
(c is TextBox)
{
if
(c.Text == "")
errorProvider1.SetError(c,
"Field Cannot be Empty");
flag = 1;
}
}
return
flag;
}
}
}
No comments:
Post a Comment