asp.net 组件开发中的内嵌资源引用_asp.net教程-查字典教程网
asp.net 组件开发中的内嵌资源引用
asp.net 组件开发中的内嵌资源引用
发布时间:2016-12-29 来源:查字典编辑
摘要:类名字空间前资源注册复制代码代码如下:[assembly:System.Web.UI.WebResource("XXX.js.FilePlu...

类名字空间前资源注册

复制代码 代码如下:

[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教程学习
    热门asp.net教程学习
    编程开发子分类