Leonard Wong leothelion96 Leonard Wong leothelion96 - 6 months ago 19
jQuery Question

How to simulate a click on LinkButton when <a> is clicked?

How can I simulate a click on the LinkButton so that CodeBehind will be read once an href is being clicked?

<asp:LinkButton ID="LinkButton_Home" runat="server" CausesValidation="False" OnClick="LinkButton_Home_Click">Home</asp:LinkButton></li>

<a href="#">Home</a>

Answer

You can trigger click event using jquery

$(document).ready(function(){
    $('a').click(function(){
         $('#'+'<%=LinkButton_Home.ClientID%>').trigger('click');
    });
});

Dont forgot to include reqired jquery library.