asp.net 组件开发中的内嵌资源引用
程序员文章站
2024-03-06 12:53:38
类名字空间前资源注册 复制代码 代码如下: [assembly: system.web.ui.webresource("xxx.js.fileplugin.js", "te...
类名字空间前资源注册
[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);
}
复制代码 代码如下:
[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);
}
上一篇: 高效的.Net UDP异步编程实现分析
下一篇: Android实现图片叠加效果的两种方法