36,758 views 127 on YTPak
90 2

Published on 26 Nov 2012 | over 4 years ago

C#, SQL Server, WCF, MVC and ASP .NET video tutorials for beginners
www.youtube.com/user/kudvenkat/playlists

In this video we will discuss about ValidationGroups and CausesValidation property.

The first problem here is that, when I click the Clear button, Form validation still happens. When I click the clear button, I just want to clear the textboxes in the Registration section. Validations doesn't make any sense here. So, how do I prevent validation from happening?
Just, set the CausesValidation property of the button control to false.

The second problem, is that when I click the Login button, only fields in the Login section(UserName and Password) needs to be validated. Along the same lines when I click the "Register" button, only fields in the Registration section(Email, UserName, Password and ConfirmPassword) needs to validated. If we don't use validation groups, then by default, whenever, you click a button, all the validation controls on the page get validated.

So, when you click the login button, and if you want only, the fields in the Login section(UserName and Password) to be validated, then set, the ValidationGroup property of the validation controls and the login button control to the same group name. Use a different group name for the validation controls and register button, in the registration section.

Loading related videos...