几个小时以来,我一直被困在一个看似非常愚蠢的问题上,无法继续前进。
基本上,如果我尝试在 ASP.NET Web 表单页面(即 Page_Load)的任何事件处理程序中评估以下内容:
ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack
我总是收到以下错误:
'System.Web.UI.IScriptManager' does not contain a definition for 'GetCurrent' and no extension method 'GetCurrent' accepting a first argument of type 'System.Web.UI.IScriptManager' could be found (are you missing a using directive or an assembly reference?)
但是,如果我在任何嵌入式 UserControls 事件中进行相同的评估,我确实会返回一个 bool 值。
我是否遗漏了一些非常基本的东西?
最佳答案
您使用的是 AjaxControlToolkit-ScriptManager 吗? 有时我在调试 IsInAsyncPostBack 值时也会遇到问题。
改变
ScriptManager.GetCurrent(Page).IsInAsyncPostBack
到
AjaxControlToolkit.ToolkitScriptManager.GetCurrent(Page).IsInAsyncPostBack
关于c# - ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack 在运行时抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5108609/