ASP.NET - RequiredFieldValidator to validate only specific controls

I have a web form. There are many different sections. I can say that in each section data of type datatable is displayed. In each section, I have the OK and Cancel buttons. When I click OK, all changes to the table in the database occur. I also added some Requiredfieldvalidators. Let's say I insert a new record in the first section, and the fields print correctly. When I click OK, I get an error message raised by other validators that are in other sections. Isn’t there a way for me to click the OK button in a specific section to get validation errors in the same area? So I probably need a button that will not act as the profiler of the page, but rather as the sender of a particular section.

+6
source share
2 answers

Put a ValidationGroup in RequiredFieldValidator . Then put the same ValidationGroup in the correct submit button. When you click on it, only the verification elements that are part of the group are checked.

http://msdn.microsoft.com/en-us/library/ms227424.aspx

+10
source

I think janhartmann is true. ValidationGroup can help you solve the problem. Check out this article

+1
source

Source: https://habr.com/ru/post/913297/


All Articles