[Solved] Asp.net button avoid pageload onclick


The framework fundamentally does not work that way. If you stay true to the framework, you can wrap your button in an update panel. That will remove the visible postback, but that will still fire the postback and perform the page load and click event.

In essence the update panel will dump your entire page into memory, then reload only the differences, simulating an ajax request.

The link submitted only allows the button to perform a JavaScript function, which would still need to Ajax to the backend.

<asp:UpdatePanel ID="upSample" runat="server" ...>
      <ContentTemplate>   
           <asp:Button id="btnSample" runat="server" ... />                              
      </ContentTemplate>                                  
</asp:UpdatePanel> 

Otherwise you should not use a server side event at all, simply do traditional html <input type="button" click="btnSample_Click()" /> that is actually doing Ajax directly to the server side.

2

solved Asp.net button avoid pageload onclick