ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack 在运行时抛出错误
我被一个看似非常愚蠢的问题困住了几个小时,无法继续前进。
基本上,如果我尝试在 ASP.NET Web 表单页面(即 Page_Load)的任何事件处理程序中评估以下内容:
ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack
我总是收到以下错误:
“System.Web.UI.IScriptManager”不包含“GetCurrent”的定义,并且找不到接受“System.Web.UI.IScriptManager”类型的第一个参数的扩展方法“GetCurrent”(您是否缺少using 指令还是程序集引用?)
但是,如果我在任何嵌入式用户控件的事件中评估相同的值,我确实会返回一个布尔值。
我错过了一些非常基本的东西吗?
it's a couple of hours that I'm stuck on what apparently seems a very silly problem and I cannot move forward.
Basically if I try to evaluate the following at any of the event handlers of an ASP.NET Web Form Page (ie at Page_Load):
ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack
I always get the following error:
'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?)
However if I evaluate the same in any of the embedded UserControls' events I do get a boolean value returned.
Am I missing something very basic?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用 AjaxControlToolkit-ScriptManager 吗?
有时我在调试 IsInAsyncPostBack 值时也会遇到问题。
更改
为
Are you using an AjaxControlToolkit-ScriptManager?
I had also sometimes problems to debug the IsInAsyncPostBack value.
Change
To
检查并确保您没有将 ScriptManager 控件命名为“ScriptManager”。如果这样做,编译器将尝试使用该控件,而不是调用 ScriptManager 类上的静态 GetCurrent 方法。
Check and make sure you didn't name your ScriptManager control "ScriptManager". If you did, the compiler will try to use that control rather than calling the static GetCurrent method on the ScriptManager class.