This is a migrated thread and some comments may be shown as answers.

DynamicDocks Error

7 Answers 259 Views
Dock
This is a migrated thread and some comments may be shown as answers.
shimon
Top achievements
Rank 1
shimon asked on 06 May 2007, 03:15 PM

Hello Telerik support,

I'm working with the Prometheus package

I'm checking the DynamicDocks example. The example "as is" is working OK.

I wanted to load into a dock a user control containing a radCalendar or a radEditor.

Unfortunately this does not work as expected – I get a JavaScript error:

Microsoft JScript runtime error: Sys.ScriptLoadFailedException: The script '/ScriptResource.axd?d=Qa-RIKglHvhv2Rt8yGi92KsrPZGbl_zWTQOOwBswCfyo84M9ZscW6S_pf6UqsSUU8zKheiaUrehVc8-xFko8YCU2rA6B-4pCe0GEipWk2-o1&t=633131126120000000' contains multiple calls to Sys.Application.notifyScriptLoaded(). Only one is allowed.

Can you help me with this? Or is a bug in the Prometheus package?

Thank you,

Shimon

7 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 08 May 2007, 06:57 AM
Hi,

The problem you experience is most probably due to the fact that you use an older version of RadEditor. Please, use the latest version and if you continue to experience any problems, write us again.


Regards,
Petya
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
shimon
Top achievements
Rank 1
answered on 08 May 2007, 08:13 AM
Hello,

I'm using "RadControls Q1 2007" and "RadControls Prometheus 2007 1 423".

Can you help with this? its very important problem.
If its not solved we can't buy the product.

Thank,
Shimon
0
Valeri Hristov
Telerik team
answered on 08 May 2007, 08:24 AM
Hello Shimon,

This problem is related to RadEditor and ASP.NET AJAX - you are using the RTM of ASP.NET AJAX and RadEditor version, which is built for older ASP.NET AJAX. If you upgrade RadEditor to its latest available version, the problem will disappear.

Greetings,
Valeri Hristov (Senior Developer, MCSD)
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
shimon
Top achievements
Rank 1
answered on 08 May 2007, 08:42 AM
Hello,

Isn't the newer version included in the Q1?

This problem occurse with RadCalendar too.

Thanks,
Shimon
0
Petya
Telerik team
answered on 08 May 2007, 10:44 AM
Hello,

We tested your scenario exactly with Prometheus RadDock and Q1 RadEditor and there seem to be no problems. Please, make sure that you are using the latest version of Atlas as well. If while using Atlas latest version you still experience problems, then please send us a simple page demonstrating the issue and we will test it right away.

Sincerely yours,
Petya
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
shimon
Top achievements
Rank 1
answered on 08 May 2007, 11:18 AM
Hello,

I'm using the ASP.NET AJAX version 1.0.
The samples code are:
Editor.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Editor.ascx.cs" Inherits="Xone8.Editor" %>
<%@ Register Assembly="RadEditor.Net2" Namespace="Telerik.WebControls" TagPrefix="radE" %>
<link href="C:\Projects\Visual Studio 2005\Projects\Xone8\Xone8\RadControls\Editor\Skins\Default\Editor.css"
    rel="stylesheet" type="text/css" />
<link href="C:\Projects\Visual Studio 2005\Projects\Xone8\Xone8\RadControls\Editor\Skins\Office2007\Editor.css"
    rel="stylesheet" type="text/css" />
&nbsp;
    <ContentTemplate>
<rade:radeditor id="RadEditor1" runat="server" skin="Office2007"></rade:radeditor>
    </ContentTemplate>

Editor.ascx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Xone8
{
    public partial class Editor : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

Test.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Xone8.Test" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        &nbsp;
    <div align="center">
        <div align="left" style="width: 612px; height: 19px">
            <asp:Label ID="Label1" runat="server" Text="Add box:"></asp:Label>
            &nbsp; &nbsp;
            <asp:DropDownList ID="DropDownList1" runat="server">
                <asp:ListItem Text="Events" Value="EventsCalendar.ascx"></asp:ListItem>
                <asp:ListItem Text="Editor" Value="Editor.ascx"></asp:ListItem>
            </asp:DropDownList>
            <asp:Button ID="btnAddBox" runat="server" OnClick="btnAddBox_Click" Text="Button" />
        </div>
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server" OnLoadDockLayout="RadDockLayout1_LoadDockLayout" OnSaveDockLayout="RadDockLayout1_SaveDockLayout">
        <TABLE>
            <TBODY>
            <TR>
                <TD>
                    <telerik:RadDockZone id="RadDockZone1" Runat="server" Height="300px">
                    </telerik:RadDockZone>
                </TD>
                <TD style="WIDTH: 100px">
                    <telerik:RadDockZone ID="RadDockZone2" runat="server" Height="300px" Width="300px">
                    </telerik:RadDockZone>
                </TD>
            </TR>
            <TR>
                <TD style="WIDTH: 100px">
                    <telerik:RadDockZone ID="RadDockZone3" runat="server" Height="300px" Width="300px">
                    </telerik:RadDockZone>
                </TD>
                <TD style="WIDTH: 100px">
                    <telerik:RadDockZone ID="RadDockZone4" runat="server" Height="300px" Width="300px">
                    </telerik:RadDockZone>
                </TD>
            </TR>
            </TBODY>
        </TABLE>
        <div style="display: none; width: 100px; height: 100px">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnAddBox" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
        </telerik:RadDockLayout>
   
    </div>
    </form>
</body>
</html>

Test.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;

namespace Xone8
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Page_Init(object sender, EventArgs e)
        {
            //Recreate the docks in order to ensure their proper operation
            for (int i = 0; i < CurrentDockStates.Count; i++)
            {
                RadDock dock = CreateRadDockFromState(CurrentDockStates[i], i);
                //We will just add the RadDock control to the RadDockLayout.
                // You could use any other control for that purpose, just ensure
                // that it is inside the RadDockLayout control.
                // The RadDockLayout control will automatically move the RadDock
                // controls to their corresponding zone in the LoadDockLayout
                // event (see below).
                RadDockLayout1.Controls.Add(dock);
                //We want to save the dock state every time a dock is moved.
                CreateSaveStateTrigger(dock);
                //Load the selected widget
                LoadWidget(dock);
            }
        }

        protected void btnAddBox_Click(object sender, EventArgs e)
        {
            RadDock dock = CreateRadDock();
            //In order to optimize the execution speed we are adding the dock to a
            // hidden update panel and then register a script which will move it
            // to RadDockZone1 after the AJAX request completes. If you want to
            // dock the control in other zone, modify the script according your needs.
            UpdatePanel1.ContentTemplateContainer.Controls.Add(dock);

            ScriptManager.RegisterStartupScript(
                UpdatePanel1,
                typeof(RadDock),
                "DockIntoZone",
                string.Format(@"
Sys.Application.add_load(function() {{
    if (typeof(Telerik.Dock{0}Moved) === 'undefined')
    {{
        $find('{1}').dock($find('{0}'));
        Telerik.Dock{0}Moved = true;
    }}
}});", dock.ClientID, "RadDockZone1"), //DropDownZone.SelectedValue
                true);

            //Right now the RadDock control is not docked. When we try to save its state
            // later, the DockZoneID will be empty. To workaround this problem we will
            // set the AutoPostBack property of the RadDock control to true and will
            // attach an AsyncPostBackTrigger for the DockPositionChanged client-side
            // event. This will initiate second AJAX request in order to save the state
            // AFTER the dock was docked in RadDockZone1.
            CreateSaveStateTrigger(dock);

            //Load the selected widget in the RadDock control
            dock.Tag = DropDownList1.SelectedValue;
            LoadWidget(dock);
        }

        protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
        {
            //Populate the event args with the state information. The RadDockLayout control
            // will automatically move the docks according that information.
            foreach (DockState state in CurrentDockStates)
            {
                e.Positions[state.UniqueName] = state.DockZoneID;
                e.Indices[state.UniqueName] = state.Index;
            }
        }

        protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
        {
            //Save the dock state in the session. This will enable us
            // to recreate the dock in the next Page_Init.
            CurrentDockStates = RadDockLayout1.GetRegisteredDocksState();
        }

        private List<DockState> CurrentDockStates
        {
            get
            {
                //Store the info about the added docks in the session. For real life
                // applications we recommend using database or other storage medium
                // for persisting this information.
                List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesMyPortal"];
                if (Object.Equals(_currentDockStates, null))
                {
                    _currentDockStates = new List<DockState>();
                    Session["CurrentDockStatesMyPortal"] = _currentDockStates;
                }
                return _currentDockStates;
            }
            set
            {
                Session["CurrentDockStatesMyPortal"] = value;
            }
        }

        private RadDock CreateRadDockFromState(DockState state, int number)
        {
            RadDock dock = new RadDock();
            dock.ID = string.Format("RadDock{0}", number);
            dock.ApplyState(state);

            return dock;
        }

        private RadDock CreateRadDock()
        {
            int docksCount = CurrentDockStates.Count;

            RadDock dock = new RadDock();
            dock.ID = string.Format("RadDock{0}", docksCount);
            dock.Title = DropDownList1.SelectedItem.Text;//string.Format("Dock {0}", docksCount);
            dock.Text = string.Format("Added at {0}", DateTime.Now);
            dock.UniqueName = Guid.NewGuid().ToString();
            dock.Width = Unit.Pixel(400);

            return dock;
        }

        private void CreateSaveStateTrigger(RadDock dock)
        {
            //Ensure that the RadDock control will initiate postback
            // when its position changes on the client. Using the
            // trigger we will "ajaxify" that postback.
            dock.AutoPostBack = true;

            AsyncPostBackTrigger saveStateTrigger = new AsyncPostBackTrigger();
            saveStateTrigger.ControlID = dock.ID;
            saveStateTrigger.EventName = "DockPositionChanged";
            UpdatePanel1.Triggers.Add(saveStateTrigger);
        }

        private void LoadWidget(RadDock dock)
        {
            if (string.IsNullOrEmpty(dock.Tag))
            {
                return;
            }
            Control widget = LoadControl(dock.Tag);
            dock.ContentContainer.Controls.Add(widget);
        }
    }
}

Thanks,
Shimon

0
Petya
Telerik team
answered on 09 May 2007, 01:22 PM
Hello,

After some testing we discovered the reason for your problem - the trial versions of RadEditor and RadCalendar that you probably use are causing the problem and since we tested with the Developers' versions of the controls, we did not see the error. We fixed the slight error and they work now. I am attaching the corrected trial versions of RadEditor and RadCalendar. Please, test with them and should you have any other issues, write us again.

All the best,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
shimon
Top achievements
Rank 1
Answers by
Petya
Telerik team
shimon
Top achievements
Rank 1
Valeri Hristov
Telerik team
Share this question
or