views:

107

answers:

1

Hi,

All ASP.Net client validation messages can be shown as an alert by setting the ShowMessageBox="True" property on the ValidationSummary control.

This works fine for anything that happens on the client.

For the custom validators that validate server-side I had assumed that what would happen is that when the page is returned to the browser, ASP.Net would inject some javascript to show the alert box. However this isnt the case.

If you had relied on the message box to show detail and just have a * next to the erroneous field (as per my clients req's) then it wont work as intended.

Does anyone have a solution for doing this? What I want is a way to possibly override the ValidationSummary control to inject javascript onto the page or something like this.

Thanks in advance.

+2  A: 

You may use Page.RegisterStartupScript to show alerts after server-side validation.

sashaeve
Coupled with a combination of overriding the ValidationSummary control and finding all controls where !IsValid, this method works nicely. I used ScriptManager.Register.... as my page is inside an update panel.
RemotecUk