Forums - C# Corner

Forum guidelines
Kevin Ljung

Kevin Ljung

  • 1.8k
  • 9
  • 107

Avoid page refresh on button click

Jul 12 2019 8:13 AM
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.

Answers (1)