Welcome Guest Search | Active Topics | Sign In | Register

Repositioning page after Callback/Callbackpanel Options
artsnob
Posted: Tuesday, April 21, 2009 8:52:01 PM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 7
I have an application built around a gridview that's working beautifully, save for one glitch.

The gridview usually extends beyond the bottom of one screen. When I used to click the pager control at the bottom, it would go to the next page of records in the control and position the page back at the top -- which is what I wanted.

Since using the callbackpanel, I no longer scroll back to the top of the page -- I get to the next group of records, but the page stays by where I clicked the pager control. I tried using the redirect feature of the callbackpanel to reposition to an anchor at the top of the page, but this didn't work out ... the page DID reposition, but none of the controls on it would work afterwards.

Is there a SIMPLE way of returning to the top after a callback? One that preferably doesn't use Javascript? If Java is necessary, can anyone show me the code and how and where to call if from VB?
eo_support
Posted: Tuesday, April 21, 2009 9:32:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You will need JavaScript for that. Here is an article about how to do this:

http://www.codeproject.com/KB/aspnet/AspNetScrollbarMove.aspx

Note that we are providing the article only for your convenience. We do not endorse the contents of the article. The principle ideal shown in this article is correct, but we are not sure about the detail.

The article uses Page.RegisterStartupScript to render JavaScript. Since you are using our CallbackPanel, you should call CallbackPanel.RenderScriptBlock instead.

Thanks!
medis
Posted: Wednesday, April 22, 2009 12:28:54 PM
Rank: Member
Groups: Member

Joined: 12/5/2008
Posts: 27
I use this with their CallBackPanel, but the panel is inside a div and it works well for me as the code is inside the script manager

<asp:ScriptManager ID="scriptmanager" runat="server" EnablePartialRendering="true" EnablePageMethods="true"/>
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('div1').scrollLeft;
yPos = $get('div1').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('div1').scrollLeft = xPos;
$get('div1').scrollTop = yPos;
}

</script>

Hope It Helps Someone ...

Bill Birt Sr.
Angel
eo_support
Posted: Wednesday, April 22, 2009 2:12:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Thank you very much for sharing!
artsnob
Posted: Wednesday, April 22, 2009 6:51:04 PM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 7
Thanks for getting back to me. Unfortunately, that code is for the opposite of what I want ... it keeps the page where it was were when the event began.

I don't see where there's a RenderScriptBlock method for callbackpanel. Would anything else in Medis' code have to be changed in light of my using callbackpanel?

All I want to happen is for the javascript scroll(0,0) command to execute in response to the pageIndexChanging or pageIndexChanged event. I can't believe all the code that seems to be necessary, and I can't get the individual parts to work in harmony. I'm not even sure where the individual parts go.


eo_support wrote:
Hi,

You will need JavaScript for that. Here is an article about how to do this:

http://www.codeproject.com/KB/aspnet/AspNetScrollbarMove.aspx

Note that we are providing the article only for your convenience. We do not endorse the contents of the article. The principle ideal shown in this article is correct, but we are not sure about the detail.

The article uses Page.RegisterStartupScript to render JavaScript. Since you are using our CallbackPanel, you should call CallbackPanel.RenderScriptBlock instead.

Thanks!
artsnob
Posted: Wednesday, April 22, 2009 7:04:03 PM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 7
Thanks, but that code looks like it's designed to keep the page in the same position. What I want is for the page to return to the TOP in response to using the pager on a gridview control in a VB project. Specifically, I want the singular Java command scroll(0,0) to fire in response to the pageIndexTurning or pageIndexTurned event of a Gridview control in a VB web project. It seems bizarre that it's so complex to accomplish such a simple task. I just don't seem to be able to get all the script, ScriptManager, ClientScript.RegisterClientScriptBlock, and Attributes.add parts to work in harmony. Do you register the code in the page load event and then attach it to a control? Can you execute the code directly from Visual Basic? The documentation on this seems to be lacking.


medis wrote:
I use this with their CallBackPanel, but the panel is inside a div and it works well for me as the code is inside the script manager

<asp:ScriptManager ID="scriptmanager" runat="server" EnablePartialRendering="true" EnablePageMethods="true"/>
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('div1').scrollLeft;
yPos = $get('div1').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('div1').scrollLeft = xPos;
$get('div1').scrollTop = yPos;
}

</script>

Hope It Helps Someone ...

Bill Birt Sr.
Angel


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.