'功能说明:防止页面滚动
Public Function RetainScrollPosition()
Dim Page As Page = System.Web.HttpContext.Current.Handler
Dim saveScrollPosition As StringBuilder = New StringBuilder
Dim setScrollPosition As StringBuilder = New StringBuilder
Page.RegisterHiddenField("__SCROLLPOS", "0")
saveScrollPosition.Append("<script language='javascript'>")
saveScrollPosition.Append("function saveScrollPosition() {")
saveScrollPosition.Append(" document.forms[0].__SCROLLPOS.value = mybody.scrollTop;")
saveScrollPosition.Append("}")
saveScrollPosition.Append("mybody.οnscrοll=saveScrollPosition;")
saveScrollPosition.Append("</script>")
Page.RegisterStartupScript("saveScroll", saveScrollPosition.ToString())
If (Page.IsPostBack) Then
If Page.Request("__SCROLLPOS") <> "" Then
setScrollPosition.Append("<script language='javascript'>")
setScrollPosition.Append("function setScrollPosition() {")
setScrollPosition.Append(" mybody.scrollTop = " & Page.Request("__SCROLLPOS") & ";")
setScrollPosition.Append("}")
setScrollPosition.Append("mybody.οnlοad=setScrollPosition;")
setScrollPosition.Append("</script>")
Page.RegisterStartupScript("setScroll", setScrollPosition.ToString())
End If
End If
End Function