c# - ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack 在运行时抛出错误

标签 c# javascript asp.net updatepanel scriptmanager

几个小时以来,我一直被困在一个看似非常愚蠢的问题上,无法继续前进。

基本上,如果我尝试在 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/

相关文章:

c# - 我的 gridview 中有 SQL Insert 问题

c# - C++/zlib/gzip 压缩和 C# GZipStream 解压失败

c# - 从 WebApi 接收 IActionResult

javascript - 我怎样才能让我的功能按计划运行?我的逻辑有错吗? (长的)

Javascript 获取并格式化当前日期

c# - [A]System.Web.WebPages.Razor.Configuration.HostSection 无法转换为 [B]System.Web.WebPages.Razor.Configuration.HostSection

c# - 没有足够的权限代表查看者发布目标

c# - 为什么这个单元测试如此 "slow"

javascript - Promise.all()的回调什么时候触发

javascript - 数据到达 Controller 但不查看