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 ).IsInAsyncPostB开发者_开发知识库ack
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?
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
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.
精彩评论