教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 asp.net 组件开发 内嵌资源引用的例子

asp.net 组件开发 内嵌资源引用的例子

发布时间:2016-01-01   编辑:jiaochengji.com
为大家提供一段asp.net 组件开发中内嵌资源引用的代码,供大家学习参考。类名字空间前资源注册。

例子代码如下:
 

复制代码 代码示例:
[assembly: System.Web.UI.WebResource("XXX.js.FilePlugin.js", "text/javascript")]
OnPreRender事件
//资源名称
string _strResourceKey = ""; //资源名称
ClientScriptManager _csm = Page.ClientScript;
//if (this.Page.Header.FindControl(_strResourceKey) == null)
//{
// string _src = _csm.GetWebResourceUrl(this.GetType(), _strResourceKey);
// Literal _literal = new Literal();
// _literal.ID = _strResourceKey;
// _literal.Text = string.Format("\n<script type=\"text/javascript\" src=\"{0}\" ></script>", _src);
// this.Parent.Page.Header.Controls.Add(_literal);
//}
//if (!this.Page.ClientScript.IsStartupScriptRegistered(_strResourceKey))
//{
// string _src = _csm.GetWebResourceUrl(this.GetType(), _strResourceKey);
// _src = string.Format("\n<script type=\"text/javascript\" src=\"{0}\" ></script>", _src);
// Page.ClientScript.RegisterStartupScript(this.GetType(), _strResourceKey, _src);
//}
if (!this.Page.ClientScript.IsClientScriptIncludeRegistered(_strResourceKey))
{
string _src = _csm.GetWebResourceUrl(this.GetType(), _strResourceKey);
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), _strResourceKey, _src);
}

您可能感兴趣的文章:
asp.net 组件开发 内嵌资源引用的例子
Android中资源文件(非代码部分)的使用概览
ASP.NET 入门的五个步骤
介绍一下Windows CE的学习路线
SQLite简介
asp.net性能优化方法-借助组件的性能优化
分享:php变量类型之资源变量
Visual C#资源文件编程--使用资源文件 <zt>-Windows开发-.NET
ASP.NET 2.0服务器控件开发
不走寻常路 设计ASP.NET应用程序的七大绝招

[关闭]
~ ~