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

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - Niyo Wong

用于主题检测的临时日志(f89708b9-f679-4391-af74-c92d9138aed4 - 3bfe001a-32de-4114-a6b4-4005b770f6d7) 测试用Word 2007发布博客 【转】ASP.NET Page事件的执行顺序 ASP.NET页面请求过程 JSP 执行过程 SQL Server 2005 错误处理笔记 .Net内存分配笔记 UML入门 与健康有约——送给每一个关心自己身体的人 .net 如何设置和检索特性信息(attribute) VC++(MFC)数据库程序——入门 T-SQL编程基础-游标 .net中的4种事务总结 T-SQL编程基础-基本语法 Javascript调用服务器端事件 模式窗口页面不更新的问题 ASP.NET菜鸟进阶-页面间参数传递 差点把这好地儿给荒废了 我们的生活离不开笑
ASP.NET菜鸟进阶-Response.Write与RegisterXXX
Niyo Wong · 2007-08-12 · via 博客园 - Niyo Wong

首先说说RegisterXXX,其包含RegisterClientScriptBlockRegisterStartupScript及用于判断的IsStartupScriptRegistered函数。
RegisterClientScriptBlock在Page 对象的元素的开始标记后立即发出客户端脚本,RegisterStartupScript则是在Page 对象的元素的结束标记之前发出该脚本。所以,如果脚本有与页面对象(doucument对象)进行交互的语句,应该使用RegisterStartupScript,反之则可以使用RegisterClientScriptBlock。RegisterClientScriptBlock和RegisterStartupScript的用法相同,包含两个参数,key表示这个脚本的唯一标识,script是待注册的脚本字符串。如下
string script = ".....";
RegisterClientScriptBlock("key", script);
为避免在页面中反复注册相同脚本,在注册脚本时使用IsClientScriptBlockRegistered判断注册关键字,如下:
If (!IsClientScriptBlockRegistered("key"))  //判断是否已经注册了关键字=key的脚本,没有则注册
{
   string script = ".....";
   RegisterClientScriptBlock("key", script);
}

Response.Write同样也是将脚本写入客户端的一种方法,不过Response.Write将脚本写到了HTML代码的最开始,也就是标签之前,如:
string script = "...";
Response.Write(script);