惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Jina AI
Jina AI
H
Help Net Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
L
LangChain Blog
Recorded Future
Recorded Future
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
GbyAI
GbyAI
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
M
MIT News - Artificial intelligence
爱范儿
爱范儿
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
B
Blog
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
The Cloudflare Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
D
DataBreaches.Net
博客园 - 【当耐特】
T
Troy Hunt's Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google Online Security Blog
Google Online Security Blog
The GitHub Blog
The GitHub Blog

博客园 - 文强

sql优化的几种方式 UpdatePanel 无刷新弹出窗口 重建主键 sql 日期时间格式转换 UpdatePanel无法直接弹出窗口的解决 A标签执行JS脚本 Guid 的几种形式 iis 5.1 连接 sql 2005 CSS 垂直居中 js 获取服务器控件 js CSS VS 打包升成可自动升级的安装包 js 弹出页面传值 提示消息后跳转 spoolsv.exe 报错,无法打印 C#获取文件的当前路径 C# web 网页刷新时数据集的保存和应用 在网页中插入CSS样式表的几种方法
.net web 点击链接在页面指定位置显示DIV的问题
文强 · 2014-01-14 · via 博客园 - 文强

做了一个网页,放了两个DataList ,一个显示科室,一个显示科室中的人员,由于科室太多,一屏显示不全,为了在页面刷新时记住上次浏览位置,所以给页面加了MaintainScrollPositionOnPostback=True 属性。

问题来了:

记住浏览位置后,由于“科室人员”继续在页顶显示,这样就还需要于拉到顶部去查看或编辑,非常不方便,没有达到记住浏览位置的本意!

试了好多方法,在科室点击显示人员的时候执行JS控制DIV位置,但是效果却是“一闪而过”,继续回到页顶!跟踪代码单步执行才知道原来提交页面时先执行了JS,然后页面又PostBack了一下,所以得到了这样的结果!

于是在网上找页面刷新后执行JS的方法,发现了这样的函数

window.onbeforeunload();在页面PostBack时执行!

window.onunload();在离开页面时执行!

本以为找到了解决的方法,在第一个函数中加了相应的控制,但问题依旧没有解决!

最后搜索时发现在使用UpdatePanel时利用RegisterStartupScript函数加载JS,于是如下解决:

1、在科室点击时加入客户端JS函数,得到人员列表应显示的位置,保存在HideField中;

2、在页面刷新Load时添加如下语句:

ScriptManage.RegisterStartupScript(System.Web.UI.Page)HttpContext.Current.CurrentHandler,typeof(System.Web.UI,Page),"showWindow","自定义函数或者语句",true);

//

问题解决!