Code Project

Link Unit

Wednesday, December 16, 2009

System.InvalidOperationException: The control with ID requires a ScriptManager on the page. The ScriptManager must appear before any controls that

System.InvalidOperationException: The control with ID requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

We faced this error while working on one of our project's page. The error appear to be very silly as Scriptmanager was declared on the page; page worked fine on it's first load. After postback,it was giving the above error. On inspecting the page further it was found the culprit was "Page.Items.Clear()" . It was clearing all objects including Scriptmanager from Page's object list.
Rule of Thumb : donot use "Page.Items.Clear()" when using Ajax

No comments: