开发者

Asp Firing All Validation Summaries

开发者 https://www.devze.com 2023-03-06 00:48 出处:网络
I need to make multiple validation summaries validate their controls and display any error messages. I have a large form that I\'ve broken into separate panels, ea开发者_如何学Pythonch with it\'s own

I need to make multiple validation summaries validate their controls and display any error messages.

I have a large form that I've broken into separate panels, ea开发者_如何学Pythonch with it's own validation group and summary. I have one button that must validate the entire page and cause all the validation groups to be validated and show the error message.

My idea is to just iterate through a collection of Validators/Validation Summaries/Validation Groups in the code behind and fire their validate events, but I'm having trouble implementing it so that the validations summaries/errors appear on the page. Any ideas?

EDIT: I made a JavaScript function to try and get it working on the client side

<script type="text/javascript">
    function validate() {
        var t1 = Page_ClientValidate("vgpEmpInfo");
        var t2 = Page_ClientValidate("vgpPanelA");

        if (!t1 || !t2) return false;

        return true;
    }
</script>

But this only validates and displays the last validation group called, in this case Panel A.


So you are looking to do it all on the client then, not the server? The server would be easier as you could call Page.Validate("group"), and that would work for all the validation summaries.

Page_ClientValidate I didn't realize that would hide all the groups... but what you could try to do is call Page_ClientValidate for all. Now I'm not sure, but I think that it might just hide the <ul> representing the list, but I'm not 100% sure, so you may be able to just show all the <ul>'s representing each summary.... otherwise, you'd have to look at validatorValidate client method. Never done this, but seems like this might work, though the latter is going to be a real pain because you have to examine custom attributes on the validator span, and process accordingly.

HTH.

0

精彩评论

暂无评论...
验证码 换一张
取 消