ASP.net中PostBack后如何保持垂直位置

本文介绍如何在ASP.NET中设置MaintainScrollPositionOnPostBack属性,以使网页回发后仍能保持用户的滚动位置不变。该功能可通过三种方式实现:在web.config文件中设置全局应用属性、针对特定页面进行设置或是通过编程方式实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When web pages are posted back to the server, by default user is returned to the top of the page. On a large web page, you might have a requirement to scroll down the user automatically to the last position on the page.

MaintainScrollPositionOnPostBack page property can be used to achieve this  in one of the following ways. 

Application level: To set the property by default for all pages in the website, open web.config and add the attribute to the pages node.

<pages maintainScrollPositionOnPostBack="true">
Page Level: for a particular page, open the aspx and set the property

<%@ Page MaintainScrollPositionOnPostback="true" ...
Code level: to set the property programmatically

Page.MaintainScrollPositionOnPostBack = true;
Hope this helps.

 

本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/Python/archive/2009/06/17/4275953.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值