Problem with ValidationSummary

I have a small contact page on my asp.net page. I have ~ 5 validators that may be wrong there, and I have ValidationSummary.

The problem ist, when I click "SubmitButton", the div wit all controls should disappear, and a div with ValidationSummary will appear.

But I have no idea how to implement this, because on the usual / linkbutton button I will not have a postback of visible / invisible DIVs. With postback, I will not have information for ValidationSummary.

I hope I can explain it correctly, so you understand me :)

+4
source share
1 answer

The check summary shows / hides itself, is that what you want to control? Anyway, you're right, you have to do this in client-side JavaScript.

One way is to manually call the Page_ClientValidate validation method and not rely on the default validation functionality.

Another way is to replace the default client functions:

var fn = Page_ClientValidate; Page_ClientValidate = function(..) { var result = fn(..); if (!!result) //Valid, else //Invalid, swap divs return result; } 

Take a look at the validation methods available to you on the client, and you can use this method to override the default implementations: http://msdn.microsoft.com/en-us/library/aa338815(v=vs.71).aspx

NTN.

+3
source

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


All Articles