views:

179

answers:

1

How can I call a js function from the "onclientclick event" of a button if this button has a ValidationGroup set ??

<asp:Button ID="btnTest" runat="server" Text="Test" OnClick="btnTest_Click"
                        ValidationGroup="ValidateMail" OnClientClick="javascript:return checkTest()" />

    <script>
    checkTest()
    {
      if(val)
       return true
     else return false
    }
    </script>
+1  A: 

It looks like you are trying to validate something on your button click.

If you are, instead of doing the validation on the button click handler, I would add a validator and have it call your checkTest() function. Don't forget to add the validator to the "ValidateMail" validation group and set CausesValidation="true" on the button.

This will cause all of the validators in the ValidateMail validation group to fire.

Is this what you were after or did I miss the point of your question?

cptScarlet
10X, It worked,...and sorry for responding so late.:)
TestSubject09