asp.net 組件開發(fā)中的內(nèi)嵌資源引用
更新時間:2011年12月22日 21:22:47 作者:
asp.net 組件開發(fā)中的內(nèi)嵌資源引用實現(xiàn)代碼,需要的朋友可以參考下。
類名字空間前資源注冊
[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);
}
復(fù)制代碼 代碼如下:
[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主機(jī)資源控制的一些心得
- asp.net(C#) 開源資源大匯總
- asp.net中資源文件的使用
- 實例講解.NET中資源文件的創(chuàng)建與使用
- .NET 資源文件resx、Resources詳細(xì)說明
- ASP.NET 服務(wù)器路徑和一般資源調(diào)用
- 詳談.net中的垃圾回收機(jī)制
- asp.net中virtual和abstract的區(qū)別分析
- ASP.NET實現(xiàn)將word文檔轉(zhuǎn)換成pdf的方法
- ASP.NET配置文件Web.config用法詳解
- ASP.net全局程序文件Global.asax用法分析
- .net非托管資源的回收方法
相關(guān)文章
微軟官方SqlHelper類 數(shù)據(jù)庫輔助操作類
本文主要介紹微軟官方的數(shù)據(jù)庫操作類極其使用方法,幫助大家利用已經(jīng)非常成熟的類庫來進(jìn)行快速開發(fā)。2016-03-03asp.net操作javascript:confirm返回值的兩種方式
asp.net操作javascript:confirm返回值分為兩種,不使用ajax、使用了ajax,不使用ajax,可以用StringBuilder來完成2014-09-09.Net RabbitMQ實現(xiàn)HTTP API接口調(diào)用
RabbitMQ Management插件還提供了基于RESTful風(fēng)格的HTTP API接口來方便調(diào)用。本文就主要介紹了.Net RabbitMQ實現(xiàn)HTTP API接口調(diào)用,感興趣的可以了解一下2021-06-06.Net Core 實現(xiàn)圖片驗證碼的實現(xiàn)示例
這篇文章主要介紹了.Net Core 實現(xiàn)圖片驗證碼的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03CreateOutputCachedItemKey 緩存key的創(chuàng)建
有關(guān)OutputCache的相關(guān)資料大家可以查看 OutputCacheProvider OutputCache的一點點認(rèn)識 ,我們還是復(fù)習(xí)一下OutputCache內(nèi)容2012-11-11ASP.NET MVC中Controller控制器向View視圖傳值的幾種方式
這篇文章介紹了ASP.NET MVC中Controller控制器向View視圖傳值的幾種方式,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-03-03