locked
Calling two functions in the OnClientClick RRS feed

  • Question

  • User-172769993 posted

    How can i call gotop() function when the function in link button returns true

    <asp:LinkButton ID="LinkButton2"  runat="server" CausesValidation="False" OnClientClick="return confirm('Are you sure you want to delete this record ?');" CssClass="btn btn-primary btn-xs" CommandName="DeleteUser" Text="Delete"><i class="glyphicon glyphicon-trash"></i></asp:LinkButton>
    
    <script>
                function gotop() {
                    var WhereToMove = jQuery("#PointA").position().top;
                    jQuery("html,body").animate({ scrollTop: WhereToMove })
                };
    </script>



    Tuesday, June 28, 2016 12:30 AM

Answers

  • User61956409 posted

    Hi asp.net4,

    You could refer to the following sample to modify the code.

    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" OnClientClick="return myfunction();" CssClass="btn btn-primary btn-xs" CommandName="DeleteUser" Text="Delete"><i class="glyphicon glyphicon-trash"></i></asp:LinkButton>
    <script>
        function myfunction() {
            if (confirm('Are you sure you want to delete this record ?')) {
                gotop();
            } else {
                return false;
            }
        }
        function gotop() {
            var WhereToMove = jQuery("#PointA").position().top;
            jQuery("html,body").animate({ scrollTop: WhereToMove })
        };
    </script>
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 28, 2016 2:31 AM