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

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - jierry

ASP.NET2.0控件一览---标准控件(2) ASP.NET2.0控件一览---标准控件(1) T-SQL tips(1)临时表和表变量 Flash Control for ASP.NET 2.0-Include Flash movies in your aspx pages 为DataGrid创建自定义列控件(四) 为DataGrid创建自定义列控件(三) - jierry - 博客园 为DataGrid创建自定义列控件(二) 为DataGrid创建自定义列控件(一) (转)SQLServer和Oracle的常用函数对比 《Effective C#》读书笔记(4) 《Effective C#》读书笔记(3) 《Effective C#》读书笔记(2) 《Effective C#》读书笔记(1) 选择合适的数据控件 自带图层的链接控件(DKLinks 1.0.0.323 ) 关于CodeBuild V3.0的一些想法 小工具:SQL存储过程解密修改工具 交叉表应用-成绩统计 现在提供第一版的存储过程生成器下载,欢迎大家试用
控件开发时两种JS嵌入资源方式的使用 - jierry - 博客园
jierry · 2006-03-15 · via 博客园 - jierry

第一种:
直接把要嵌入的JS文件属性设置为“嵌入的资源”。

protected override void OnInit(EventArgs e)
{
      
base.OnInit (e);
       
if(!base.Page.IsStartupScriptRegistered("Script"))
        
{
                Assembly assembly 
= typeof(TestControl).Assembly;
                StreamReader reader 
= null;
                 reader 
= new StreamReader(assembly.GetManifestResourceStream(typeof(TestControl),"test.js"));
                
                
base.Page.RegisterStartupScript("Script",reader.ReadToEnd());

         }

}

第二种:
创建相同类名的资源文件,然后在Data出的name设置为Test,value为js的内容。

protected override void OnInit(EventArgs e)
{
      
base.OnInit (e);
      
if(!base.Page.IsStartupScriptRegistered("Script"))
       
{
               ResourceManager resx 
= new ResourceManager(base.GetType());
               
base.Page.RegisterStartupScript("Script",resx.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture,true,true).GetString("Test"));

        }

}

上面两种方式都是在控件类中输出JS代码,也可以自定义HttpHandler来生成Js代码。