-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();