Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation on panels

Status
Not open for further replies.

mrathi

Technical User
Oct 27, 2003
115
US
Hi,

I have created some panels on one form. Each panel has some textboxes and one button to save and continue. When I click the button, it does the validation for that panel. It will not proceed to the next panel if there are errors on the panel. I also have links to go to various panels and that does not do any validation. On the last panel, I have a button to submit the data from all the panels. At this submission, I want to do validation for all the panels and not just for the last panel? How should I implement this?

Thanks
 
If you made each validation control as CustomValidator control, then you could just call a function that called the ServerValidate event of each CustomValidator.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I would seperate your validation code for all 3 panels into 3 seperate functions, each one returning a string that represents an error. Check the return error message after each call. If you have one, the validation fails and set the message to a label.

When you get to the 3rd panel, call the respective functions to validate, concatenating your string of errors. Like this:

strErrorMessage = ValidatePanel1
strErrorMessage += ValidatePanel2
strErrorMessage += ValidatePanel3

At this point, check the variable strErrorMessage to see if you had a return error. If so, set it to a label for the user to see and do not proceed. If there was no error, proceed.

Mark
 
I did not create any custom validation. All my validation does is checks if the required field has data in it, or if the range of data in the textbox is valid.

Also, do you mean that when I click the button on the last panel, I should write some code behind it to check the validation on the first three panels as well? If so, how can I do this? It would be helpful if you can provide some example code with it.

Thanks for your responses.
 
mrathi,

There is a good article on the CustomValidator control at
If you read that article it will show you how to implement your custom validation and how to call the function that runs the validation.

There is also some sample code provided so this should help you.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top