The code below shows some HTML with a <asp:Button>
element.
<asp:Button ID="CalculateG481" runat="server" Text="Calculate" OnClick="CalculateG481_Click" />
This calls the function CalculateG481_Click
but then posts back.
I have tried using OnClientClick="return false"
but this simply prevents the button from executing CalculateG481_Click
I have also tried OnClick="CalculateG481_Click; return false;"
as well to no avail.
EDIT: CalculateG481_Click
is a C# Codebehind function.
The way you are doing is really strange - you cannot call Server-Side Button Event from Client-Side JavaScript .
You can either use regular input html tag with pure Client-Side calculation or Server Button Control with Ajax based on your requirement.
Easiest way is to use Ajax UpdatePanel , and place everything inside it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.