click() not behaving like user click
- by rpiontek
I have searched for a solution to this for the last several hours but to no avail. When I click on a button that has a return false in OnClientClick, no postback occurs to the server. When I use jquery to trigger the click function of the button, OnClientClick fires first, but regardless of the return value, a postback occurs. Here's a simple sample...
<form id="form1" runat="server">
<div>
<asp:Button ID="Button2" OnClientClick="$('#Button1').click();" runat="server" Text="Trigger" /><br />
<asp:Button ID="Button1" OnClick="Button1_Click" OnClientClick="return false;" runat="server" Text="Button" />
</div>
</form>
So, in this example, when Button1 is clicked normally, no postback occurs. When Button2 is clicked, a postback always occurs. Is this a bug or intended behavior?