Search code examples
c#javascriptasp.netupdatepanelscriptmanager

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


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?


Solution

  • Are you using an AjaxControlToolkit-ScriptManager? I had also sometimes problems to debug the IsInAsyncPostBack value.

    Change

    ScriptManager.GetCurrent(Page).IsInAsyncPostBack
    

    To

    AjaxControlToolkit.ToolkitScriptManager.GetCurrent(Page).IsInAsyncPostBack