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

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - 四海

定时提醒助手 kettle 创建任务定时执行数据抽取 js 图形化工作流设计器 更新树层结构 工作流设计 jquery 固定行列可编辑表格-jfixed 简单实用ORM框架 oracle 数据库实体生成工具 Js 弹出框 返回值的两种常用方法 c#做的查看sybase数据库表 sql 查询执行顺序 转载网络ASP与SQL Server存储过程 有创业兴趣的来看看 一个有用的存储过程 marquee中嵌入datalist 滚动 XMLHttpRequest 对象 System.Web.HttpRequestValidationException:解决方法 实现业务系统中的用户权限管理--实现篇 实现业务系统中的用户权限管理--设计篇
Page.ClientScript.RegisterStartupScript()
四海 · 2008-12-12 · via 博客园 - 四海

使用类型、键、脚本文本和指示是否添加脚本标记的布尔值向 Page 对象注册启动脚本。

参数

type

要注册的启动脚本的类型。

key

要注册的启动脚本的键。

script

要注册的启动脚本文本。

addScriptTags

指示是否添加脚本标记的布尔值.

备注:

启动脚本由它的键和类型唯一标识。具有相同的键和类型的脚本被视为重复脚本。只有使用给定的类型和键对的脚本才能使用该页面进行注册。试图注册一个已经注册的脚本不会创建重复的脚本。

调用 IsStartupScriptRegistered 方法以确定具有给定的键和类型对的启动脚本是否已经注册,从而避免不必要的添加脚本尝试。

RegisterStartupScript 方法的此重载中,使用 addScriptTags 参数可指示 script 参数中提供的脚本是否包装在 <script> 元素块中。将 addScriptTags 设置为 true 指示脚本标记将自动添加。

RegisterStartupScript 方法添加的脚本块在页面加载完成但页面的 OnLoad 事件引发之前执行。

示例

<%@ Page Language="C#"%>
<script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";
String csname2 = "ButtonClickScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
String cstext1 = "alert('Hello World');";
cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}
// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRegistered(cstype, csname2))
{
StringBuilder cstext2 = new StringBuilder();
cstext2.Append("<script type=text/javascript> function DoClick() {");
cstext2.Append("Form1.Message.value='Text from client script.'} </");
cstext2.Append("script>");
cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), false);
}
}
</script>
<html>
<head>
<title>ClientScriptManager Example</title>
</head>
<body>
<form id="Form1"
runat="server">
<input type="text" id="Message"> <input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>