2011-05-17 73 views
0

與更新面板的用戶控件使用scriptManger註冊一個腳本這個代碼是工作時:ScriptManager.RegisterStartupScript

ScriptManager.RegisterStartupScript 
     (this.updatePanel, this.updatePanel.GetType(), "printing", Keys.URL, true); 

但這個不起作用

ScriptManager.RegisterStartupScript(this, this.GetType(), "printing", Keys.URL, true); 

我無法弄清楚,爲什麼?

回答

6

我想這是因爲在第一個例子,你要註冊一個腳本UpdatePanel(這將在異步回發來更新 - 使寫入腳本),而在第二個例子中,你正在做的在page級別,由於它不在UpdatePanel之外,所以不會更新。

+0

是非常正確的,因爲更新面板用於部分回發,所以腳本沒有在第二次加載頁面,因爲部分回發 – Devjosh 2011-05-17 10:11:40

相關問題