Last post Mar 16, 2017 03:08 PM by micang73
Mar 16, 2017 02:53 PM|micang73|LINK
I am using webform, asp.net, Visual Studio 2015, C#
I have a webform that a list of textboxes, buttons and listboxes. What I am trying to do is a user can build a list of items (these list of items (report criteria) are used to pull back data to display on the screen or export to excel).
The user types in a value in the textbox, clicks the button to add the value to the listbox (the user can also click on an item in the list box to remove it). Once all the criteria is chosen the user click a button to view or export the data.
The problem I am facing is when the user scrolls down the page and they click on the button to add to the list box, the webpage refreshes and the page now scrolls back to the top. This happens on the button click and on the listbox click - I understand that
this is because of postback.
I am kind of stuck as I can't think of a way to prevent this?
Any suggestions will be greatly appreciated.
Mar 16, 2017 03:03 PM|mgebhard|LINK
I'm not sure if you want to stop the post back or maintain the scroll position. I guessing the later. Set
MaintainScrollPositionOnPostBack=true in the page directive.
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="WebFormDemo._default" %>
Mar 16, 2017 03:08 PM|micang73|LINK
You are correct, I still need the postback, but at the same time maintain the scroll position.
Thank you so much for the help, I was not aware of that feature/function.
Appreciate your help.