Show an ASP.NET Validation Summary in a jQuery UI Modal Message
I've made an ASP.NET web form that uses the standard 开发者_如何转开发ASP.NET validation. I'd like to make the error summary show up in a jQuery UI Modal Message as well as below the actual form.
Is it possible to execute the script if the validation finds an error?
You could hijack or override the ASP.net page validation function. This removes the need for an extra CustomValidator.
Here's a description of how to accomplish this.
Keep the validation summary in a hidden div
, like Mike suggested.
Then in your overridden function, call the original function to do the actual validation and display that div
as the modal window.
I used the idea in the link provided by GeReV and here is what I came up with, in case someone needs it: Check here.
Let me add a note: Don't vote-down this post in case if it has to be a comment. I don't see a option to add comment.
You could do this with a CustomValidator. Set the ClientValidationFunction
property to be a javascript function that would execute your desired jQuery.
Just for reference, here's an in-depth look at how you can manipulate validators on the client side.
You can put the validation messages in a hidden div
so that they would fill the div
on some errors. Then manually show the ui modal specifying the content would be the content of the div
.
精彩评论