Portal Engine
Version 2.x > Portal Engine > AJAX ScriptManager View modes: 
User avatar
Member
Member
boodapotamus - 12/16/2007 8:00:09 PM
   
AJAX ScriptManager
I have succesfully implemented web parts using AJAX extensions on a CMS site. Since I use multiple instances of these webparts, I placed an instance of ScriptManager is the Master Page tab of Root in the CMS Desk.

As I stated everything works fine on the front end. My problem is that when using the design tab, everytime I make additions/subtractions or up/down changes to the webparts I recieve the following error.

"Only one instance of a ScriptManager can be added to the page."

I understand the error message, but just not sure how to correct it since the SprcitManger is only referenced once on the Master Page. Any suggestions?

User avatar
Member
Member
Mufasa - 1/23/2008 11:24:27 PM
   
RE:AJAX ScriptManager
I have the same problem. I can only assume that is because some code that is run after any Web Part modification is manually adding another ScriptManager to the page without checking for an existing one.

I tried using the ScriptManagerProxy element in the master page instead, but apparently the ScriptManager element is only added after a Design -> Web Part modification, so you can not assume the existence of a ScriptManager in most cases.

I couldn't find any instance being created by the supplied CMS code (via several different Find All searches). I tried browsing around in the compiled Kentico DLLs (IL code) but didn't find it there either (although that was just a manual search in a couple of DLLs and methods I thought it might be in).

So, I couldn't find a workaround. Kentico, do you have one for us?

User avatar
Kentico Developer
Kentico Developer
kentico_jakubo - 1/25/2008 10:45:15 AM
   
RE:AJAX ScriptManager
Hello,

In the code file (aspx or ascx) you have declaration of scriptmanager

<asp:ScriptManager ID="myScriptManager" runat="server" />

In the code behind try use this.

myScriptManager = ScriptManager.GetCurrent(this.Page);

This should be using only one instance of script manager on the page.





User avatar
Member
Member
Mufasa - 1/25/2008 3:21:35 PM
   
RE:AJAX ScriptManager
That's a good idea too. The only problem is that there is not always a ScriptManager on the page. You have to put it on the Master page yourself to have it in most cases. But in the case where a user is in Design mode, the CMS code adds a whole new ScriptManager no matter what. *That* code needs to try that code and only add it's own ScriptManager if one is not found in the first place. It doesn't. That's the problem.

I think I'll post in the bugs forum about this.

User avatar
Member
Member
Mufasa - 1/25/2008 3:28:04 PM
   
RE:AJAX ScriptManager
I posted this issue in the Bugs forum as well:

http://www.kentico.com/DevNet/Forums.aspx?ForumID=7&Thread=00003930

User avatar
Member
Member
kentico_vitaja - 1/29/2008 3:08:00 PM
   
RE:AJAX ScriptManager
Hello,

I would like to inform you that Kentico 2.3a is not fully supporting AJAX and therefore I would like to recommend you to wait for release of Kentico 3.0.

Best regards,
Vita Janecek

User avatar
Member
Member
Mufasa - 1/29/2008 4:23:49 PM
   
RE:AJAX ScriptManager
I don't want *full support*, I just want it to allow me to use it without *prohibiting* its use. That's all. Can we get a little hotfix? It'll take two lines of code...

When adding the ScriptManager, simply check the Page's ScriptManager's Current property for null first. If so, add the ScriptManager element.
Regardless of this if block, the next line would be to add whatever script(s) are necessary in Design mode to the single instance of the ScriptManager.

User avatar
Member
Member
kentico_vitaja - 1/29/2008 7:54:55 PM
   
RE:AJAX ScriptManager
Hello,

Kentico CMS 3.0 was just released. Could you please confirm that your issues related to ScriptManager are solved with this release?

Best regards,
Vita Janecek

User avatar
Member
Member
Mufasa - 2/1/2008 4:26:44 PM
   
RE:AJAX ScriptManager
Version 3.0 does fix the issue in that a ScriptManager is always included now. Thank you.

Of course, now I have to create a new thread in the New Features forum so I can request to be able to replace the standard ASP.NET AJAX ScriptManager control with the more robust AJAX Control Toolkit version of the ScriptManager that allows automatic script combining and other useful features.

User avatar
Member
Member
damian-brandcape.co - 8/28/2011 3:30:58 PM
   
RE:AJAX ScriptManager
Came across this thread while try to handle the duplicate Script Manager issue (Kentico loads Scriupt Man by default, and it can conflicet with Ajax methods) So you need to do something like this if you're working in controls (web parts)

http://stackoverflow.com/questions/183950/add-scriptmanager-to-page-programmatically

protected override void OnInit(EventArgs e)
{
Page.Init += delegate(object sender, EventArgs e_Init)
{
if (ScriptManager.GetCurrent(Page) == null)
{
ScriptManager sMgr = new ScriptManager();
Page.Form.Controls.AddAt(0, sMgr);
}
};
base.OnInit(e);
}