简体   繁体   中英

In EWL, how do I clear scroll position when navigating to the same page with different query parameters?

I am on MyPage.aspx?questionNumber=1 and I am navigating to MyPage.aspx?questionNumber=2. I am using this code create the navigation between the two:

EwfUiStatics.SetContentFootActions( new ActionButtonSetup( "Next",
                                                                           EwfLink.Create(
                                                                               new Info( es.info, new OptionalParameterPackage { QuestionNumber = info.QuestionNumber + 1 } ),
                                                                               new ButtonActionControlStyle() ) ) );

Notice I am using "new Info" and re-using the entity's info object. Maybe I should be using GetInfo or something else, instead.

When I get to the next question, I am scrolled halfway down the page. I want to be at the top. How do I force the scroll position to be cleared (or more generally, how do I specify the info object so that I don't have undesired carry-over from the previous page)?

The way you navigate (including whether you reuse Info objects or not) makes no difference in what is retained. Even something like this (in a DataModification ) would produce the same results you're seeing:

parametersModification.QuestionNumber += 1;

Currently EWL does not have strong support for picking and choosing the state you want to retain after an intra-page navigation. But for scroll position in particular, you may be able to override EwfPage.scrollPositionForThisResponse to get what you want. You could unconditionally return ScrollPosition.TopLeft as long as the page never does post backs in which you want to retain scroll position.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM