ScriptManager.GetCurrent (Page) .IsInAsyncPostBack throws an error at runtime

After a couple of hours, I was stuck on what seems to be a very stupid problem, and I can't move forward.

Basically, if I try to evaluate the following in any of the ASP.NET web form page event handlers (for example, in Page_Load):

ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack

I always get the following error:

"System.Web.UI.IScriptManager" does not contain a definition for "GetCurrent", and there is no extension method "GetCurrent" that takes the first argument of the type "System.Web.UI.IScriptManager" (if you missed the using directive or the assembly reference?)

However, if I evaluate the same in any of the UserControls built-in events, I get the returned boolean value.

Do I miss something very simple?

+3
source share
2 answers

Are you using AjaxControlToolkit-ScriptManager? I also had problems debugging IsInAsyncPostBack.

Edit

ScriptManager.GetCurrent(Page).IsInAsyncPostBack

For

AjaxControlToolkit.ToolkitScriptManager.GetCurrent(Page).IsInAsyncPostBack 
+6
source

Check and make sure that you do not specify the ScriptManager "ScriptManager" control. If you did, the compiler will try to use this control instead of calling the static GetCurrent method in the ScriptManager class.

+1
source

Source: https://habr.com/ru/post/1794518/


All Articles