-1
所以我有以下问题。我为servercontrol创建了一个基类,以使开发脚本控件更加容易。ASP.Net WebForms IE7 ScriptManager.RegisterClientScriptInclude不起作用
我去下面的方式来实现这一目标:
if (!Page.ClientScript.IsClientScriptIncludeRegistered(Page.GetType(), "scriptControl.js"))
ScriptManager.RegisterClientScriptInclude(Page, Page.GetType(), "scriptControl.js", this.ResolveUrl("~/Layouts/scriptControl.js"));
var relScriptPath = GetRelativeScriptUrlPath();
if (!string.IsNullOrEmpty(relScriptPath))
{
var relativeToken = "relativeScript" + ClientConstructorName;
if (!Page.ClientScript.IsClientScriptIncludeRegistered(Page.GetType(), relativeToken))
ScriptManager.RegisterClientScriptInclude(Page, Page.GetType(), relativeToken, this.ResolveUrl(relScriptPath));
}
ScriptManager.RegisterStartupScript(Page, Page.GetType(), ClientID, string.Format("scriptControl.registerAndExecute('{0}','{1}');", ClientConstructorName, ClientID), true);
奇怪的是这工作就好在几乎每一个浏览器除了
一堆狗屎
IE7
大多数浏览器的结果是:
-> load scriptcontrol.js (debug alert notification)
-> load specific.js (debug alert notification)
-> scriptExecute
IE7的结果是:
-> load scriptcontrol.js (debug alert notification)
-> scriptExecute (exception. js function as declared in spefific.js not defined because it apparently wasn't run)
还有其他人遇到类似的问题吗?迄今为止,我的研究没有产生任何帮助。
在一个旁注:
我的js文件已完成了其解决的问题我记得之前beeing类似行:
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();