在使用scriptManger注册脚本时,在带有更新面板的usercontrol中,此代码有效:
ScriptManager.RegisterStartupScript
(this.updatePanel, this.updatePanel.GetType(), "printing", Keys.URL, true);
Run Code Online (Sandbox Code Playgroud)
但是这个不起作用
ScriptManager.RegisterStartupScript(this, this.GetType(), "printing", Keys.URL, true);
Run Code Online (Sandbox Code Playgroud)
我想不清楚为什么?
我认为这是因为在第一个例子中你注册了一个脚本UpdatePanel(它将在异步回发上更新 - 启用脚本编写),而在第二个例子中你是在这个page级别上执行它,不会更新,因为它不属于UpdatePanel.