Leonard Wong leothelion96 Leonard Wong leothelion96 - 2 years ago 86
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 Source
    $('#' + '<%=btn_login.ClientID%>').trigger('click');

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download