如果页面比较长,当页面发生回传(POSTBACK)时总是出现不能恢复到回传前的页面位置,有什么办法可以确保页面回传以后的位置还是原来的位置?
谁能把以下的翻译成VB
防止页面滚动#region 防止页面滚动
private void RetainScrollPosition()
{
StringBuilder saveScrollPosition = new StringBuilder();
StringBuilder setScrollPosition = new StringBuilder();
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.onscroll=saveScrollPosition;");
saveScrollPosition.Append("</script>");
RegisterStartupScript("saveScroll", saveScrollPosition.ToString());
if (Page.IsPostBack)
{
setScrollPosition.Append("<script language='javascript'>");
setScrollPosition.Append("function setScrollPosition() {");
setScrollPosition.Append(" mybody.scrollTop = " + Request["__SCROLLPOS"]+ ";");
setScrollPosition.Append("}");
setScrollPosition.Append("mybody.onload=setScrollPosition;");
setScrollPosition.Append("</script>");
RegisterStartupScript("setScroll", setScrollPosition.ToString());
}
}
#endregion
[此贴子已经被作者于2006-2-22 17:09:09编辑过]