简体   繁体   中英

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.

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;

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM