Kevin Ljung

Kevin Ljung

  • NA
  • 30
  • 14.4k

Avoid page refresh on button click asp.net

Jul 12 2019 8:13 AM
Hi.
Im using a button like this:
  1. <asp:Button ID="btnShowAvailableReports" class="btnBasic" OnClick="btnShowAvailableReports_Click" runat="server" Text="View reports" />  
and this button click event triggers a div placeholder which hold the available reports.
 
The problem is that this reloads the page and re-renders the basic information on the page.
If I then click the menu item where this information is it shows properly as it should - but I have to re-click the menu item to get back due to the page refresh.
 
I have tried:
 
- Add button property OnClientClick="return false;"
This blocks my onclick-event that I need.
- Use page header: <%@ Page Language="C#" MaintainScrollPositionOnPostBack="true" Title="Home" %>
 
This seems to do nothing at all.
 
Thankful for all help.
Cheers.

Answers (1)