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

推荐订阅源

M
MIT News - Artificial intelligence
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
J
Java Code Geeks
G
Google Developers Blog
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
月光博客
月光博客
B
Blog
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
博客园_首页
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
Jina AI
Jina AI
S
SegmentFault 最新的问题
H
Help Net Security
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News

博客园 - Kevin

换工作了,记录一下面试情况 打工的就是打工的! 超强的希捷硬盘 如何一次性取出每个类别下的前n条记录 在一个表里添加了一记录,怎样取得这条记录的id 发布程序到远程服务器 DNN所有表结构 web.config信息及RSA加密方式! Using JavaScript to show the current time for the end user HtmlGenericControl操作meta标记 window2k3集成sp1光盘启动工具版 CodeSmith资源 华硕网站ajax应用分析-js脚本 Ajax程序设计入门 SQL Server端口更改后的数据库连接方式 windows2003server自带防火墙导致sql server2k无法访问,谁有好办法? 局域网访问access数据库 dreamweaver+asp+access+vss不该犯的错误 windows2k3server远程桌面连接,”终端服务器超出了最大允许连接数“的解决办法
vs2005调用js脚本方法总结
Kevin · 2005-12-29 · via 博客园 - Kevin

1 Using the RegisterClientScriptBlock method

<%@ Page Language=”VB” %>
<script runat=”server”>
Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs)
Dim myScript As String = “function AlertHello() { alert(‘Hello ASP.NET’); }”
Page.ClientScript.RegisterClientScriptBlock(
Me.GetType(), “MyScript”, _
myScript, 
True)
End Sub

</script>
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
<title>Adding JavaScript</title>
</head>
<body>
<form id=”form1” runat=”server”>
<div>
<asp:Button ID=”Button1” Runat=”server” Text=”Button”
OnClientClick
=”AlertHello()” />
</div>
</form>
</body>
</html>

<%@ Page Language=”C#” %>
<script runat=”server”>
protected void Page_Load(object sender, EventArgs e)
{
string myScript = @”function AlertHello() { alert(‘Hello ASP.NET’); }”;
Page.ClientScript.RegisterClientScriptBlock(
this.GetType(),
“MyScript”, myScript, 
true);
}

</script>

2 Using Page.ClientScript.RegisterStartupScript

Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs)
Dim myScript As String = “alert(document.forms[0][‘TextBox1’].value);”
Page.ClientScript.RegisterStartupScript(
Me.GetType(), “myKey”, myScript, _
True)
End Sub

protected void Page_Load(object sender, EventArgs e)
{
string myScript = @”alert(document.forms[0][‘TextBox1’].value);”;
Page.ClientScript.RegisterStartupScript(
this.GetType(),
“MyScript”, myScript, 
true);
}

3 Using the RegisterClientScriptInclude method

Dim myScript As String = “myJavaScriptCode.js”
Page.ClientScript.RegisterClientScriptInclude(“myKey”, myScript)

string myScript = “myJavaScriptCode.js”
Page.ClientScript.RegisterClientScriptInclude(“myKey”, myScript);

This creates the following construction on the ASP.NET page:
<script src=”myJavaScriptCode.js” type=”text/javascript”></script>