我有一个webform,长度超过一屏,其中有一些按钮,一按的话,页面就刷新一下,然后跳到页首,很是不爽。不知道有什么办法,就是刷新但是屏幕能翻到原来的地方。请大家帮忙想想办法。
在aspx顶部:
<%@ Page SmartNavigation="True" ...%>
加上SmartNavigation="True"
在刷新的按钮事件中加上“Page.RegisterStartupScript("111","<script language=javascript>scrollTo(screen.width , screen.height);</script>");”
让它到客户端去执行
Is it possible to prevent a Web form from scrolling to the top of the page when it posts back to the server?
http://www.wintellect.com/resources/faqs/default.aspx?faq_id=1&page=7#6