views:

27

answers:

2

Hi,

Does anyone know how to maintain postback while calling WebForm_DoCallback? it always set the vertical scrollbar of the page to the very top.

thanks

A: 

on the page you want to maintain position set the following page level directive:

<%@ Page Language="..." MaintainScrollPositionOnPostback="true" ... %>

If you wanted you could set this for the whole site, in which case add the following to your web.config under the system.web block:

 <pages maintainScrollPositionOnPostBack="true" />
Naeem Sarfraz
tried it even before posting the thread!
A: 

i had similar problem yesterday after {don't remember what changes}.
the MaintainScrollPositionOnPostback just stopped working.

use this:

string postbackInvokerUniqueID = Request.Forms["__EVENTTARGET"];
if (!string.IsNullOrEmpty(postbackInvokerUniqueID))
    Page.FindControl(postbackInvokerUniqueID).Focus();

that may not give the the exact scroll position, but is close enough

y34h
I placed the code on page_load event but no luck. any ideas?