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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - 稽首本然

Nhibernate 教程,有空看看 Jquery专题写的不少,有空看看,另该研究下门面模式了! Java开源权限管理中间件 《需求规格说明书》业务描述活动图 《需求规格说明书》(用例)陷阱 《需求规格说明书》核心功能表现方式(用例) LINQ TO SQL ScriptManager与UpdatePanel总结 Nunti测试工具使用整理 一个关于NHiberante,Linq数据源与UI交互引发的思考 数据库联接字符串 LINQ TO OBJECT ASPX直接编写脚本function后使用javascript Aspx页面中直接编写javascript脚本 ASPNET跨页面传值技巧总结 javascript捣乱程序 Javascript在Asp.Net中的应用汇总 AjaxPanel中使用javascript AjaxPanel控件说明
母版事件中注册javascript脚本
稽首本然 · 2011-01-18 · via 博客园 - 稽首本然

母版事件中注册javascript脚本

☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆

Title      :㈠母版等事件中注册javascript脚本
Description:
version    : 1.0              Date      :8:46 2008-3-26       
Author       : TianzhenYu/田振宇/Nick(Tim)  Contact    :MSN:zhenyu_tian@hotmail.com
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆

//★★★①步骤:
//Create Websit defaultPage.aspx
//Create DispalyTime.js TimIndex目录下有源js文件
//创建一个MasterPage模版
//在其Page_preRender中可以加载Javascript脚本,如下:

//★★★②代码分析:
       
//模版列中PreRender事件
protected void ContentPlaceHolder1_PreRender1(object sender, EventArgs e)
    {
        LoadScript();
    }

//注册脚本
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
//提示:    string scriptUrl = Server.MapPath("~/javascript/displayTime.js"); //因为是母版 所以用~
    scriptmanger.RegisterClientScriptInclude(scriptType, scriptname, ResolveClientUrl(scriptUrl));
//☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆

private void LoadScript()
    {
        string scriptname = "displayTime";
        string scriptUrl = Server.MapPath("~/javascript/displayTime.js");
        Type scriptType = this.GetType();//获取当前类型
        ClientScriptManager scriptmanger = Page.ClientScript;
    //脚本注册
        if (!scriptmanger.IsClientScriptIncludeRegistered(scriptType,scriptname))
        {
            scriptmanger.RegisterClientScriptInclude(scriptType, scriptname, ResolveClientUrl(scriptUrl));
        }
    }
//前台页面中就可以使用脚本了
//..
<div id="currentTime"></div>
//最后将此模版指定给对应的页面default2.aspx就可以获得效果了...