**////
/// 功能:在页面post时保存屏幕滚动状态;
/// 直接在Page_Load中加入Zeda.CNE.Common.RetainScrollPosition();
/// 不能加在if(!Page.IsPostBack){}内;
/// 加入的两个隐藏域为__SCROLLPOS_TOP和__SCROLLPOS_LEFT
///
public static void RetainScrollPosition()
{
System.Web.UI.Page page=(Page)HttpContext.Current.Handler;
page.RegisterHiddenField("__SCROLLPOS_TOP","0");
page.RegisterHiddenField("__SCROLLPOS_LEFT","0");
string saveScrollPosition = "";
string setScrollPosition = "";
page.RegisterStartupScript("saveScroll", string.Format(saveScrollPosition,"window.document.body"));
if (page.IsPostBack)
{
page.RegisterStartupScript("setScroll", string.Format(setScrollPosition,"window.document.body", page.Request.Form["__SCROLLPOS_TOP"],page.Request.Form["__SCROLLPOS_LEFT"]));
}
}
本文作者:佚名 来源:http://www.bjcan.com
CIO之家 www.ciozj.com 微信公众号:imciow