Leonard Wong leothelion96 Leonard Wong leothelion96 - 6 months ago 20
HTML Question

Simulate a click from <button> on <asp:button>

I am trying to simulate a click from #btn_new_login to #btn_login. So when the user click #btn_new_login, it will simulate a click on #btn_login as well.

<button id="btn_new_login" onclick="document.getElementById('btn_login').click();">Login</button>

<asp:Button ID="btn_login" runat="server" Text="Login" OnClientClick="return checkfields()" OnClick="btn_login_Click" />

Answer
$('#btn_new_login').click(function(e){
    e.preventDefault();
    $('#' + '<%=btn_login.ClientID%>').trigger('click');
});

Try this code. This should work if your checkfields method is returning true.

Comments