Student wrote:
Good evening,
I create a three tier ASP.NET web application. How can I validate the
form input data in the Business Logic Layer? Can anyone give me an
example?
Well, what I do, is in the submit method, you could take the values of
your form, and run them through your validation methods. If the
validation returns false, then don't do a Server.Transfer to the next
page, put the user back on form where the problem is
private void bookingSubmit_Click(object sender, System.EventArgs e)
{
if(this.validateForm())
{
//data is ok; proceed
Server.Transfer("nextpage.aspx");
}
}
//this method could be in the "business logic layer"
bool validateForm()
{
if(this.FirstName.Length==0)
return false;
//... and so on
}