开发者

Triggering ASP ValidationGroup validation upon page load

I'm looking for a way to trigger ASP.NET validator controls upon a page loading.

I have a ValidationSummary and a series of RequiredFieldValidators and CheckBoxListValidators on my page all assigned to the same ValidationGroup. When the button that is tied to the validation group is clicked the page is properly validated.

I've attempted to use JavaScript on the client side using both the function ValidatorValidate() and Page_ClientValidate(). When I attempt to use both of these i开发者_StackOverflowtems I get an "Object Expected" error in IE8. What exactly am I supposed to pass into these functions? The ValidationGroup or each individual control I want to validate? I've looked at various tutorials and blog posts and it all seems so simple, yet I'm left scratching my head trying to figure out these functions.


You need to do it in the onload event of the HTML.

Option 1

<html onload="Page_ClientValidate()">

Option 2, jQuery

<script type="text/javascript">
    jQuery(function() {
        Page_ClientValidate();
    })
</script>


Untested, but in theory in your Page_Load you could call something like:

Page.Validate()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜