Block an asp:Button OnClick event in C# from the OnClientClick event in JavaScript?
问题 I have an asp:Button on my webpage, and it calls into a JavaScript function and a code-behind method. The latter makes a call to navigate to another page. In the JavaScript function, I'm checking for a condition. If this condition is not met, I want to abort the navigation so that the OnClick method is not called. Is this possible? <asp:Button OnClick="Button_Click" ID="Action1" OnClientClick="SaveValues()" Text="Action1" CssClass="specialButton" runat="server" /> 回答1: To block OnClick from