[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1263
  • Last Modified:

maintainscrollposition not maintaining scroll position

hi all, i've got an intranet page displaying sortable gridview that is being refreshed every 10 minutes.  i've added maintainscrollposition header, but when page refreshes, not only does the user get sent back to top of page, they also lose their sort selection.

sort is being done in gridview using session state variable.  page is posted when user selects a value from atuopostback drop down list (day/week/month/year).  strange thing is when the user sorts by column b, then selects different time value from day/week/month/year, the sort is maintained upon the page refresh.  but when the page refreshes from the http meta count, i lose the sort and page position.

how do i maintain page position and sort when using the refresh method below???

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableViewState="false" MaintainScrollPositionOnPostback="true" %>

<head id="Head1" runat="server">
    <title>Realtime Sales</title>
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="expires" content="-1" />
    <meta http-equiv="refresh" content="15" />
</head>


codebehind
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["TimeFrameIndex"] != null)
            {
                TimeFrame.SelectedIndex = (int)Session["TimeFrameIndex"];
                TimeFrame_SelectedIndexChanged((object)Session["sender"], (EventArgs)Session["e"]);
            }
            Session["COLUMN_SORT_NAME"] = "APP PREMIUM";
            Session["COLUMN_SORT_ORDER"] = "DESC";
        }
        GetData();
    }


thanks
0
aaalife
Asked:
aaalife
  • 3
  • 2
1 Solution
 
RejojohnyCommented:
when a page is refreshed using the meta tag .. it is not submitting the page .. but just refreshing .. so for the server the page is been requested for the first time .. thats the reason why it does not maintain the scroll or the sort position ..

u could give this a try ...

instead of meta refresh u could use "settimeout" to call a function which will submit the page every 10 minutes ..

window.setTimeout("MyFunction", 600);

function MyFunction
{
  document.all.submit();
}
0
 
aaalifeAuthor Commented:
that's worse.  upon refresh i get a pop up window saying "page cannot be refreshed without resending information - click retry to send info again, or cancel", then i lose sort and position.

0
 
RejojohnyCommented:
refresh will popup that message if previous action to that page was a "postback" ... its the behaviour of the browser ...

>> then i lose sort and position
even when u click on "retry"?

Rejo
0
 
aaalifeAuthor Commented:
when i click refresh in browser, scroll position and sort are maintained, this is after clicking ok on retry? box.  i need to know how to maintain scroll/position upon the 10 minute page refresh.
0
 
RejojohnyCommented:
>>i need to know how to maintain scroll/position upon the 10 minute page refresh
am not sure thats possible using meta refresh .. when u click on "retry" after u "refresh" the page, u r actually submitting the page again using the same parameters as ur previous refresh .. that the reason y it maintains the sort and scroll position .,.

Rejo
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now