Archive for the ‘Uncategorized’ Category

Adding a Script Manager dinamically on a SharePoint web part

September 19, 2008

One of the common problems with the authoriting of SharePoint web parts using ajax (System.Web.Extensions) is the necesity of add a ScriptManager control to the page.

Usually you must add one ScriptManager Control to your page or to the Master Page, but you must be sure of have only one per page. I see many samples where add the ScriptManager to controls collection of the web part, but in many cases don’t check if already exist a ScriptManager.

In one of my projects i has the necesity of  create a web part that automaticly detect if already exist a ScriptManager on the page and if not add it.

The first i found is the posibiltiy to use the function ScriptManager.GetCurrent to get the the ScriptManager asociated to the page, and use it to add the script manager on the CreateChildControls if not found a ScriptManager already using the GetCurrent.

But very soon i begin to recieve errors.. i go to finish this soon…