Reputation: 65
I want to validate a code, and if it is correct than send the data on page to DB.
Here are the functions:
ValidateCode(object send, EventArgs e)
{ logic here}
And the submit button code:
Register_Clicked(object sen, EventArgs e)
So within the Register click I want to fire the ValidateCode
function and if it is correct than only save data.
Upvotes: 1
Views: 105
Reputation: 3442
First, make sure your ValidateCode() function returns a boolean value (true if validation is passed; false otherwise):
ValidateCode(object send, EventArgs e)
{
// logic here
// return boolean value
if (passed) {
return true;
}
return false;
}
Then you can add this in your register_clicked function:
Register_Clicked(object send, EventArgs e)
{
if (ValidateCode(send, e)) {
// validation passed code
} else {
// validation failed code
}
}
Upvotes: 1