Shuaib
Shuaib

Reputation: 753

LinkButton onclientclick not working

I have a linkbutton declared like this

        <asp:LinkButton ID="btn_update" class="btn btn-success" runat="server" OnClientClick="return validate(event);" Onclick="btn_update_Click"><span class="icon-ok icon-white"></span> Update</asp:LinkButton>

In my javascript I have this code

jQuery(document).ready(function () {


        alert("0");

        function validate(event) {

            alert("1");

        }


    });

My client side script is not firing at all. Alert(0) is firing but Alert(1) is not firing.

There are many stackoverflow threads addressing the same problem. But I coded exactly as told in the answers there, but to no avail. I am puzzled now.

Upvotes: 0

Views: 489

Answers (1)

Shuaib
Shuaib

Reputation: 753

I took the function out of document.ready() and it worked just fine.

jQuery(document).ready(function () {

    alert("0");

});

function validate(event) {

        // put some validation 

       return true;

    }

Upvotes: 1

Related Questions