i´m develping a small webpart, and i´m having some issues when i use the radScheduler with the asp:UpdatePanel.
The webpart has one radScheduler and a few cotrols more, but not many.
Hte scheduler is inside an updatePanel when an event happens like when i click on the header to change the view (day, weeks, or months) a javascript error display saying b.Month.Model or b.TimeLine.Model is null or not an object. After that the control doesn´t render properly and it doesn´t work as expected.
I´ve tried different ways and small examples but i can´t fix it.
Here is the source code, is quite simple...
<
asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadScheduler runat="server" ID="SchedulerPrueba" ShowHeader="true"
DataKeyField="Id"
DataSubjectField="Subject"
DataStartField="EventDate"
DataEndField="EndDate"
>
</telerik:RadScheduler>
</ContentTemplate>
</asp:UpdatePanel>
Nothing on the code-behind
Thanks
15 Answers, 1 is accepted
This is a known issue with ScriptManager in SharePoint - controls can't register scripts on the fly and RadScheduler uses exactly such scripts.
We don't have a reliable solution for now, but we have a few workarounds. The first one is to register the control scripts manually and set SchedulerPrueba.EnableEmbeddedScripts = false
. See the attached snippet.One other thing that you can try is to call EnsureChildControls in OnInit:
protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
EnsureChildControls();
}
We're researching for a proper solution meanwhile, but so far we don't have much luck.
I hope this helps.
Best wishes,
Tsvetomir Tsonev
the Telerik team
I have tried the
EnsureChildControls
method, and it didn't work for me. And unfortunately it does not seem like the Script Manager approach is fitting as well. Or maybe I'm missing something. The problem is that the web part requires that I have a ScriptManager control on the page in order to work properly, and placing a RadScriptManager on the user control page creates a conflict. So I thought that maybe I can use the web part's script manager to register the scripts in the web part class, and I still had no luck getting it to work - basically I can switch a view only once, and after that I get no reaction.Using the existing ScriptManager instance will work fine - obtain a reference by calling ScriptManager.GetCurrent(Page). Make sure you register the scripts on each request.
What is the error message you see when you switch views?
Kind regards,
Tsvetomir Tsonev
the Telerik team
Ok, here's my progress report:
I'm currently registering the scripts in the web part class, in the protected override void OnLoad(EventArgs e) event. The script registration looks like this:
ScriptManager scriptManager = ScriptManager.GetCurrent(Page);
if
(scriptManager !=
null
)
{
string
telerikAssembly =
typeof
(RadScheduler).Assembly.FullName;
scriptManager.Scripts.Add(
new
ScriptReference(
"Telerik.Web.UI.Common.Core.js"
, telerikAssembly));
//...And so on
By the way, I had to add one more script to the registration from your example, otherwise the context menu was not working properly. The Telerik.Web.UI.Scheduler.ContextMenu.RadScheduler.ContextMenu.js was missing.
I'm seeing the following behavior:
- Sharepoint 2010:
- if i have the dubbuger on, then this error is caught:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Mon, 13 Sep 2010 16:17:27 UTC
Message: Sys.InvalidOperationException: Two components
with
the same id
'ctl00_m_g_b04b5ece_fbd4_4f78_b65d_5f172766d6d5_ctl00_CWCalendar_SelectedDateCalendar'
can't be added to the application.
Line: 4044
Char: 59
Code: 0
URI: http:
//win-dwsgqbxiuwm/ScriptResource.axd?d=MKkwUF8aaV_gwl_p_2wR9BiN2hfwkJ4UaaNemv6ltcPZ26LYFaw8Su-gSY0yVw56fhh_gZoP9IOKd6bkBRGOhOyeSQbUL67_yrjfeJaOgkw1&t=ffffffffba2f01c1
and then the page works okay.
- if i don't have the debugger on, then the page loads with a js error notification at the bottom. on a wiki page it's the same error as above, and on a web part page, the error is this:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Mon, 13 Sep 2010 15:58:24 UTC
Message:
'this._viewIDs.length'
is
null
or not an object
Line: 259
Char: 32
Code: 0
URI: http:
//win-dwsgqbxiuwm/ScriptResource.axd?d=QXIXrIbLbks8YJyEE126-0FiP0kHQOjSCMxUHpU0i0p8XVtpWvfo7OJQ0m_oldLVNNoRsN7OGw8rSg6MUvCJZI9Kf5h-79x1JnipJbwyf6VAKat3iVInqmOnmjAcULI10&t=3bacbfee
and the view will switch only once.
- Sharepoint 2007:
- the loading panel callback does not work at all, the views switch through a post back. no js error occurrs.
Thank you for the update.
It seems that SharePoint 2010 doesn't call the dispose method of the client-side control objects. We'll try to reproduce the issue locally and we'll get back to you.
I hope we'll be able to work around those SharePoint quirks.
Greetings,
Tsvetomir Tsonev
the Telerik team
i have another issue to fix, it´s about the navigation command on the week and month view, when the user clicks on the date it fires the following error.
Because f is null, there is any way to fix this because i´m also trying to cath the event OnClientNavigationCommand but i can´t.
Apologies for the late reply.
I tried few different set-ups, but I always got correct behavior - partial updates worked and I didn't get JavaScript errors in SP2010. I'm attaching you the web part source code for reference.
Are you sure that you're using the correct assembly version? It should end with .35 for SP2010.
Alberto, the problem is caused by a mistake that I've made when listing the scripts that RadScheduler requires. The Helpers.DateTime.js must be the first one of the Scheduler scripts. Here's the correct script list, including the correction from Dasha:
Telerik.Web.UI.Common.Core.js
Telerik.Web.UI.Common.jQuery.js
Telerik.Web.UI.Common.jQueryPlugins.js
Telerik.Web.UI.Common.Popup.PopupScripts.js
Telerik.Web.UI.Common.Navigation.NavigationScripts.js
Telerik.Web.UI.Menu.RadMenuScripts.js
Telerik.Web.UI.Menu.ContextMenu.RadContextMenuScripts.js
Telerik.Web.UI.Input.TextBox.RadInputScript.js
Telerik.Web.UI.Input.DateInput.RadDateInputScript.js
Telerik.Web.UI.Input.NumericTextBox.RadNumericInputScript.js
Telerik.Web.UI.Calendar.RadTimeViewScripts.js
Telerik.Web.UI.Calendar.RadCalendarCommonScript.js
Telerik.Web.UI.Calendar.RadCalendarScript.js
Telerik.Web.UI.Calendar.RadDatePicker.js
Telerik.Web.UI.Calendar.RadDateTimePickerScript.js
Telerik.Web.UI.ComboBox.RadComboBoxScripts.js
Telerik.Web.UI.Scheduler.Helpers.DateTime.js
Telerik.Web.UI.Scheduler.RadSchedulerScripts.js
Telerik.Web.UI.Scheduler.RecurrenceEditor.RecurrenceEditor.js
Telerik.Web.UI.Scheduler.ContextMenu.RadScheduler.ContextMenu.js
Telerik.Web.UI.Scheduler.Views.Week.Model.js
Telerik.Web.UI.Scheduler.Views.Week.GroupedByResource.Model.js
Telerik.Web.UI.Scheduler.Views.Week.GroupedByDate.Model.js
Telerik.Web.UI.Scheduler.Views.MultiDay.Model.js
Telerik.Web.UI.Scheduler.Views.MultiDay.GroupedByResource.Model.js
Telerik.Web.UI.Scheduler.Views.MultiDay.GroupedByResource.Model.js
Telerik.Web.UI.Scheduler.Views.Day.Model.js
Telerik.Web.UI.Scheduler.Views.Day.GroupedByResource.Model.js
Telerik.Web.UI.Scheduler.Views.Month.Model.js
Telerik.Web.UI.Scheduler.Views.Month.GroupedByResource.Model.js
Telerik.Web.UI.Scheduler.Views.Month.GroupedByDate.Model.js
Telerik.Web.UI.Scheduler.Views.Timeline.Model.js
Telerik.Web.UI.Scheduler.Views.Timeline.GroupedByResource.Model.js
Telerik.Web.UI.Scheduler.Views.Timeline.GroupedByDate.Model.js
Telerik.Web.UI.Scheduler.Scheduling.AdvancedTemplate.js
I hope this helps.
Kind regards,
Tsvetomir Tsonev
the Telerik team
Thanks a lot for your reply.
Thank you so much for your help and a great example. Once I put all the calls into their correct places, the ajax call back and the loading panel worked as expected on SP 2010! This is great, I'm very excited! I knew that I had the timing wrong, I just could not figure it out. What's your verdict on SP 2007? I still see the page posting back when I switch views, even with your latest changes applied.
There's a known issue with SP2010 that might be the culprit in your case. Please see this help topic:
http://www.telerik.com/help/aspnet-ajax/create-ajax-enabled-sharepoint-webpart-radcontrols.html
Try adding the code from the help article to the OnInit method to see if that helps.
protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
Page.ClientScript.RegisterStartupScript(
typeof
(Web_Part1),
this
.ID,
"_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;"
,
true
);
if
(
this
.Page.Form !=
null
)
{
string
formOnSubmitAtt =
this
.Page.Form.Attributes[
"onsubmit"
];
if
(!
string
.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt ==
"return _spFormOnSubmitWrapper();"
)
{
this
.Page.Form.Attributes[
"onsubmit"
] =
"_spFormOnSubmitWrapper();"
;
}
}
}
Have a nice day.
Sincerely yours,
Tsvetomir Tsonev
the Telerik team
Thank you for replying and I apologize for taking so long to get back to you. I had other projects that were prioritized...
I tried your suggestion in a SharePoint 2007 web part, and it's still doing a full post back instead of an ajax callback when I switch views or go to the next month. Would it be too much trouble to ask you to try putting together an example of a 2007 web part for me so i can see what I'm doing wrong?
Not sue if they are related, but figured I'd let you know.
I've replied to you in the other forum post - let's keep the discussion there is a good chance that both issues are related.
Greetings,
Tsvetomir Tsonev
the Telerik team