当前位置:Gxlcms > asp.net > asp.net 组件开发中的内嵌资源引用

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

时间:2021-07-01 10:21:17 帮助过:40人阅读

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

人气教程排行