Asp.net team had designed script manager such that only one instance existed per page(HttpHandler), i can’t find a valid reason why they had extended a method like ScriptManager.GetCurrent to get the instance inside a page. Why couldn’t developers do
if(ScriptManager == null)
{
throw new Exception("The Below ajax control requires ScriptManager in the page");
}
I believe because there might be other places than the code behind file of the page to access the actual ScriptManager. With the static method GetCurrent() you can access the ScriptManager of the current context from anywhere in the code (e.g. from a class library). The implementation of GetCurrent looks like this:
Therefore it’s just a shortcut to get access to the ScriptManager instance.
Your code would not work from a content page or a user control, when the ScriptManager is defined on the master page.