admin管理员组

文章数量:1309146

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?

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?

Share Improve this question edited Oct 16, 2019 at 5:29 abatishchev 100k88 gold badges301 silver badges442 bronze badges asked Feb 24, 2011 at 18:02 Giuseppe RomagnuoloGiuseppe Romagnuolo 3,4022 gold badges31 silver badges38 bronze badges 1
  • What version of .Net is this? In 4.0 there's not even an IScriptManager interface, seems like this is a 2.0 thing. If you're not using .NET 2.0 is this possibly a library version conflict? Check your assembly references. – Jamie Treworgy Commented Feb 24, 2011 at 21:59
Add a ment  | 

2 Answers 2

Reset to default 6

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 piler will try to use that control rather than calling the static GetCurrent method on the ScriptManager class.

本文标签: cScriptManagerGetCurrent ( Page )IsInAsyncPostBack throws an error at runtimeStack Overflow