In my project I am creating normal ASP .NET user controls, then wrap them up as Sharepoint (using 2010) web parts for deployment. Everything works fine in Sharepoint if there is an instance of the Rad Control already visible on the page. However, sometimes I only have one instance of the control in the page and it starts out Visible = false. When I trigger an event to show the control I get things that no longer work. For example, RadNumericTextbox will throw a javascript error, RadDatePicker and RadTimerPicker will no longer popup the picker if I click on the icon. This looks like it's because the script resource for the controls aren't loaded initially because they are hidden. If I use styles and set "display: none" then it's fine, Creating hidden controls in the master page would work but it would be better if there was something I can set, perhaps in the RadScriptManager, to do this.
Thanks,
Gilbert
8 Answers, 1 is accepted
Indeed you are right. This is a known issue in Sharepoint 2010. The script resources are not loaded if the controls are not visible initially. One workaround available for now would be to add the appropriate javascript files for the controls manually through the RadScriptManager. Please refer to the following help topic for detailed explanation on how to do this.
All the best,Marin
the Telerik team

Thanks for the response. Manually registering them does work. I guess I'll have to register all the scripts for the Rad Controls that I need to be using? I manage to find a similar thread after seeing your reply.
http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/sharepoint-2010-ajax-with-detailsview.aspx
Since I'm using RadDatePicker as well is there plans to include Telerik.Web.UI.Calendar.RadPickersPopupDirectionEnumeration.js into the assembly?
Thanks,
Gilbert
Yes, you need to register the scripts for all the controls that you are using on the current page.
The referenced script should be present in the telerik assembly, you need to add it when using RadDatePicker.
Marin
the Telerik team

even though this is a pretty old post, I want to share some workaround I found that is related to the "Sharepoint 2010 not emitting javascript links on partial postback" problem (or as you call it: "Hidden ajax radcontrols not registering scripts in sharepoint"). In general the problem occurs, if controls are added (OR made visible) during a partial postback.
The solution is to override GetScriptRefererence and add all Telerik scripts manually instead of letting the ScriptManager
do the work (see the example for a RadComboBox):
public
class
MyComboBox : RadComboBox {
protected
override
System.Collections.Generic.IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
{
IEnumerable<ScriptReference> baseReference =
base
.GetScriptReferences();
foreach
(ScriptReference reference
in
baseReference)
{
ScriptManager.RegisterClientScriptResource(
this
,
this
.GetType().BaseType, reference.Name);
}
return
new
List<ScriptReference>();
}
}
This might be not the best solution, however it works, i.e. ScriptReferences added this way will be rendered in a partial post back scenarios as well.
If you add the scripts manually, you don't let the ScriptManager (or the ScriptManagers "OnResolveScriptReference" handler respectively, ...just a hint), decide what scripts to include and what scripts to ignore.
Kind regards, Andreas
Thank you very much for sharing this solution. It is really a nice workaround.
Also I am happy to inform you that Microsoft has finally addressed this issue as well in one of the Sharepoint 2010 cumulative updates for October 2011. Installing this update should generally fix the problems with hidden ajax controls registering their scripts.
Marin
the Telerik team

thank you for the reply. Do you have an idea of the exact Microsoft KB Issue that addresses this problem?
Kind regards, Andreas
I think it should be this one:
http://support.microsoft.com/kb/2596505
Marin
the Telerik team

However, for the reason of completeness, I would like to provide you with a better solution that also makes sure, ScriptReferences are only added to the list of client script resources once. It is important to make sure, that these scripts are not added multiple times since otherwise the script loading may fail at the client side (due to multiple javascript calls to:
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
public
class
MyComboBox : RadComboBox
{
protected
override
System.Collections.Generic.IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
{
#if MANUAL_SCRIPT_POSTBACK_FIX
HashSet<
string
> registeredNames =
new
HashSet<
string
>();
ReadOnlyCollection<RegisteredScript> registeredScripts = ScriptManager.GetCurrent(Page).GetRegisteredClientScriptBlocks();
foreach
(RegisteredScript registeredScript
in
registeredScripts)
{
registeredNames.Add(registeredScript.Key);
}
foreach
(ScriptReference reference
in
base
.GetScriptReferences())
{
if
(!registeredNames.Contains(reference.Name))
{
ScriptManager.RegisterClientScriptResource(
this
,
typeof
(MyComboBox).BaseType, reference.Name);
}
}
return
new
List<ScriptReference>();
#else
return
base
.GetScriptReferences();
#endif
}
}
You can control the behaviour with the compiler symbol MANUAL_SCRIPT_POSTBACK_FIX
Again, not an optimal solution, but its working.
Kind regards, Andreas