DotNetNuke 6 and the Registered Script Control Error

If you’ve made the transition from DotNetNuke 5 to DotNetNuke 6 you’ve probably discovered that the AJAX Toolkit controls don’t play nice with DotNetNuke any more.  Fortunately the Telerik AJAX controls have been bundled with DotNetNuke for version 6.  I’ve discovered that converting to the Telerik controls has been beneficial and worth the upgrade.

Still, it can be a pain getting the code right.  One particular error that I ran into today was the Registered Script Control error.  It looks something like this:

Script control ‘{controlname}’ is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().  Parameter name: scriptControl

The error results from “stacked” AJAX controls.  Consider the following HTML

<%@ Register TagPrefix=”dnnui” Namespace=”DotNetNuke.Web.UI.WebControls” Assembly=”DotNetNuke.Web” %>
<%@ Register TagPrefix=”DNN” Namespace=”DotNetNuke.UI.WebControls” Assembly=”DotNetNuke.WebControls” %>

<DNN:DNNTabStrip ID=”tabsProject” runat=”server” TabRenderMode=”All” Visible=”true”>

<DNN:DNNTab runat=”server” Label-Text=”Properties” ID=”tabGeneral”>

<dnnui:DnnAjaxPanel runat=”server” ID=”dapMain”>

<asp:Label runat=”server” ID=”lblInfo”></asp:Label>

</dnnui:DnnAjaxPanel>

</DNN:DNNTab>

<DNN:DNNTab runat=”server” Label-Text=”Properties” ID=”tabSecond”>

<dnnui:DnnAjaxPanel runat=”server” ID=”dapSecond”>

<asp:Label runat=”server” ID=”lblMessage”></asp:Label>

</dnnui:DnnAjaxPanel>

</DNN:DNNTab>

</DNN:DNNTabStrip>

Let’s say that the second tab (tabSecond) should only appear under certain conditions; a record was created, a particular user is logged, whatever the condition is doesn’t matter, just that the tab should appear at certain times and not appear at other times.

In the code behind the condition block might look like this:

if (condition) then

tabSecond.Visible = False

end if

But this results in the Registered Script Control error.  Modify the condition block this way:

if (condition) then

dapSecond.EnableAJAX = False

tabSecond.Visible = False

end if

This should resolve the error.

What was the issue?  I’m glad you asked.

The issue causing the error is that AJAX controls are registered with the AJAX script manager and cannot be unregistered, or moved.  Hiding an AJAX control is equivalent to moving it from the script.  In order to circumvent that we’re disabling AJAX on the control before it has a chance to be rendered and registered with the script manager.

Leave a Reply

Your email address will not be published. Required fields are marked *