ScriptManager in a BasePage class.

вторник, 15 януари 2008 г.

Hi guys!
As I don't have much time I will go straight to the problem - how we can put ScriptManager in our BasePage class? You know that when you insert an UpdatePanel to a page and there isn't any ScriptManager it cries for one. When you insert more than one ScriptManager, you are said that there isn't any. As I have researched - there wasn't answer how you can put ScriptManager from a BasePage class and again we were alone ;).

OK here is the solution:

How you can come to this conclusion yourself?
When you open the code of the UpdatePanel you will see that the class has property ScriptManager, which internaly calls ScriptManager.GetCurrent(page) which internaly returns (page.Items[typeof(ScriptManager)] as ScriptManager);

So I had to do two things - first to lie the UpdatePanel that there is at least one ScriptMangaer, than I had to remove it because I want to add it as first control on the page.

Thats all folks! Hope this helps :-).

Vesko Kolev's Blog : IDeveloper -