开发者

ASP.NET Custom Validators - Page.Validate("groupName") not firing?

I have a custom validator in which the script validating the control is client-side JavaScript.

In my VB code behind for the website I call Page.Validate("groupName") but my validation script is not fired at all. I placed a break point in my JavaScript, but it's not even touching my validation script. While when I use the same function on non-custom validators it works.

I am thinking that it is impossibly to call my client-side validation script in my VB behind code via Page.Validate("groupName"). Do I absolutely need a server-side validation function?

Here's a bit of code:

<asp:CustomValidator ID="ValidateTxt" runat="server" 
     ClientValidationFunction="validateTxt" 
     ControlToValidate="txtBox" 
     Display="Dynamic"
     ValidationGroup="group1">
</asp:CustomValidator>

 <script type="text/javascript" language="javascript" >
    function validateFinHeight(source, arguments)
    {
         if(arguments.Value % 2 == 0 ){
            arguments.IsValid = true;
         }             
    }
 </script>

VB Behind Code:

Protected Sub cbo(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbo.SelectedIndexChanged
    Page.Validate("group1")
E开发者_如何学Pythonnd Sub

The Page.Validate("group1") is not calling my JavaScript function.


Page.Validate is used to validate at Server side. If you want to trigger the client side validation then call the function Page_ClientValidate("group1") from your JavaScript code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜