Class name space Pre-resource registration
Copy Code code as follows:
[Assembly:System.Web.UI.WebResource ("XXX.js.FilePlugin.js", "Text/javascript")]
OnPreRender Events
Resource Name
String _strresourcekey = ""; Resource Name
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);
}