When displaying a RadWindow while scrolled to the bottom of the page, the window is rendered at the top the of the page and I have to scroll back up to see the window.
I'm maintaining post back scroll position by setting 'MaintainScrollPositionOnPostback':
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
I have a RadListView where the ItemTemplate has a button in it. When that button is clicked, I display a RadWindow modal.
The problem is if I scroll to the bottom of the page and click the button, the page displays the window at the top of the page, but then scrolls back down to where user was scrolled at (due to MaintainScrollPositionOnPostback). So the window is displayed off screen until user scrolls back up
How can I show the RadWindow where the user is scrolled at on postback? (Not at top of page)
I've tried displaying RadWindow 2 different ways but both have same result
Way 1:
Window.VisibleOnPageLoad = true;
Way 2:
string script = "function f(){$find(\"" + RadWindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
Add a timeout around
show()
to let the scrolling take place before you open the RadWindow. Otherwise, here is what happens:postback returns, page is not scrolled
RadWindow shows up, centers in the current viewport
scrolling shifts so your RadWindow is not where you expect it
Here is an example:
where you can tweak the 111ms timeout I added for illustrative purposes. Using 0 as an argument may also suffice. To be honest, I don't know how long it takes for the scroll to shift.
By the way, I would create a JS function in the markup that would take the ID of the RadWIndow as an argument and call that instead, just to make the code more readable