Asp.net团队设计了脚本管理器,每页只存在一个实例(HttpHandler),但我无法找到有效的原因,他们为什么扩展了像ScriptManager.GetCurrent
这样的方法来获取实例页面。为什么不能开发人员做ScriptManager.GetCurrent方法背后的原因
if(ScriptManager == null)
{
throw new Exception("The Below ajax control requires ScriptManager in the page");
}
我猜ScriptManager是ScriptManager控件的ID,对吧?当ScriptManager位于MasterPage上时,您无法从用户控件访问该ID。 – slfan 2012-02-15 18:01:29
@slfan对不起,我没有放下这里的情况。无论是任何asp文件(usercontrol,masterpage,子页面,嵌套masterpage)。 Asp.net团队(很多人都在不断改进)设计了一种方法来识别页面中的ScriptManager实例,但是他们没有在页面中的那个请求/响应中设置“Current”ScriptManager类(可能有一个ID像sManager,resourceManager等),就像我知道我可以在启用memebership时使用'User.Identity.Name'来登录人员的用户名。我有种感觉,这是纯粹的传统,为未来作出的决定:) – Deeptechtons 2012-02-16 04:38:35