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

RadDockingManager In MOSS Web part

1 Answer 79 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
Pravat
Top achievements
Rank 1
Pravat asked on 13 May 2008, 01:37 PM
Hi,

I had created a web part which uses Rad Docking Control and i am getting one error when i try to add two or more web parts containing RadDockingManager onto the MOSS page. The error is

"Only one instance of RadDockingManager is allowed on the page. Please remove RadDockManager1 control."

The web part is created using a user control which contains all the html portion of the web part.

The html for the UserControl is as follows:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MYItem.ascx.cs" Inherits="MY.UserControls.MYItem" %> 
<%@ Register Assembly="RadDock.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %> 
<%@ Register TagPrefix="radcb" Namespace="Telerik.WebControls" Assembly="RadComboBox.NET2" %> 
 
 
<rad:RadDockingManager ID="RadDockingManager1" runat="server" /> 
 
<rad:RadDockingZone ID="RadDockingZone1" runat="server"
    <rad:RadDockableObject ID="RadDockableObject1" runat="server"
        <ContentTemplate> 
            <asp:Panel ID="PanelConfig" runat="server" Visible="false"
                <radcb:radcombobox MarkFirstMatch="true" AllowCustomText="false"  Sort="Descending" id="RadComboBox1" Skin="Default" Width="300px" AutoPostBack="false" RadComboBoxImagePosition="Right" Height="140px" Runat="server"></radcb:radcombobox> 
                <asp:Button id="Button1" runat="server" Text="Select" OnClick="Button1_Click" CssClass="CommandButton"></asp:Button> 
                <br /><br /> 
            </asp:Panel> 
            <iframe id="iframeGrid" height="417px" width="655px" frameborder="0" scrolling="yes" runat="server" src="~/utils/pleasewait.aspx"></iframe> 
        </ContentTemplate> 
        <Commands> 
            <rad:RadDockableObjectCommand AutoPostBack="true" Image="../images/icon_edit.gif" Name="edit"></rad:RadDockableObjectCommand> 
            <rad:RadDockableObjectCommand AutoPostBack="true" Image="../images/icon_clsdfold.gif" Name="closeedit" /> 
        </Commands> 
    </rad:RadDockableObject> 
</rad:RadDockingZone> 
 

The code for the web part that contains this user control is as follows:
using System; 
using System.Runtime.InteropServices; 
using System.Web.UI; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Serialization; 
 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.WebControls; 
using Microsoft.SharePoint.WebPartPages; 
using System.ComponentModel; 
 
namespace MY.Parts 
    [DefaultProperty("Text"), 
ToolboxData("<{0}:MYWP runat=server></{0}:MYWP>"), 
       XmlRoot(Namespace = "MY.Parts")] 
    public class MYWP : Microsoft.SharePoint.WebPartPages.WebPart 
    { 
 
        private const string defaultText = ""
        private string _userControl = defaultText;         
        private Control _control = null
        private ScriptManager _AjaxManager; 
 
 
        [Browsable(true), 
            Category("User Control"), 
          DefaultValue(defaultText), 
            WebPartStorage(Storage.Personal), 
            FriendlyName("User Control (.ascx)"), 
            Description("Path to the User Control (.ascx)")] 
        public string UserControl 
        { 
            get 
            { 
                return _userControl; 
            } 
 
            set 
            { 
                _userControl = value
            } 
        }         
 
        public MYWP() 
        { 
            this.ExportMode = WebPartExportMode.All; 
        } 
 
        protected override void CreateChildControls() 
        { 
            base.CreateChildControls(); 
 
            try 
            { 
                if ((this._control == null) && (this.Page != null)) 
                { 
                    try 
                    { 
                        if (_userControl != defaultText) 
                        { 
                            if ((this._userControl != "") && (this._userControl.IndexOf("~") != -1)) 
                            { 
                                thisthis._control = this.Page.LoadControl(this._userControl);                                 
                            } 
                        } 
                        else 
                        { 
                            _control = new LiteralControl(string.Format("To link to content, <href=\"javascript:MSOTlPn_ShowToolPaneWrapper('{0}','{1}','{2}');\">open the tool pane</a> and then type a URL in the Link text box.", 1, 129, this.ID)); 
                        } 
                    } 
                    catch (Exception exception) 
                    { 
                        this._control = new LiteralControl(string.Format("<b>Error:</b> unable to load {0}<br /><b>Details:</b> {1}", this._userControl, exception.Message)); 
                    } 
                } 
            } 
            catch (System.Exception ex) 
            { 
                _control = new LiteralControl(string.Format("<b>Error:</b> unable to load {0}<br /><b>Details:</b> {1}", _userControl, ex.Message)); 
            } 
 
            if (_control != null) 
            { 
                // Add to the Controls collection to support postback 
                this.Controls.Add(_control); 
            } 
        } 
 
        protected override void RenderWebPart(HtmlTextWriter output) 
        { 
            EnsureChildControls(); 
            if (_control != null) 
            { 
                _control.RenderControl(output); 
            } 
        } 
 
        protected override void OnInit(EventArgs e) 
        { 
            try 
            { 
                base.OnInit(e); 
                this._AjaxManager = ScriptManager.GetCurrent(this.Page); 
                if (this._AjaxManager == null) 
                { 
                    this._AjaxManager = new ScriptManager(); 
                    this._AjaxManager.EnablePartialRendering = true
                    this._AjaxManager.EnableScriptLocalization = true
                    this.Page.ClientScript.RegisterStartupScript(typeof(MYWP), this.ID, "_spOriginalFormAction = document.forms[0].action;", true); 
                    if (this.Page.Form != null) 
                    { 
                        string str = this.Page.Form.Attributes["onsubmit"]; 
                        if (!string.IsNullOrEmpty(str) && (str == "return _spFormOnSubmitWrapper();")) 
                        { 
                            this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();"; 
                        } 
                        try 
                        { 
                            this.Page.Form.Controls.AddAt(0, this._AjaxManager); 
                        } 
                        catch (Exception ex) 
                        { 
                            this.Controls.AddAt(0, this._AjaxManager); 
                        } 
                    } 
                } 
            } 
            catch (Exception ex) 
            { 
            } 
        } 
 
        [WebPartStorage(Storage.None)] 
        public ScriptManager AjaxManager 
        { 
            get 
            { 
                return this._AjaxManager; 
            } 
            set 
            { 
                this._AjaxManager = value
            } 
        } 
 
    } 
 

If i add this web part twice in different zones of MOSS page then i get the above mentioned error. How do i resolve this issue???

Can we check if the RadDockingManager is present on the MOSS page and then may be add that to the controls collection of the web part if it is not present. This is quite similar to the ScriptManager ( AjaxManager ) being added in the above mentioned Web part code. Can we do this???

I got one link which says that RadDockingManager could be added to the master page ie in this case would be MOSS master page(which ever it would be not sure which one) to resolve the issue.
http://www.telerik.com/community/forums/thread/b311D-mkcdm.aspx

Which master page do i need to change and how do i add the RadDockingManager control in it???


Please help ASAP.

Thanks and Hoping to get a quick response.


Regards
Saurabh


1 Answer, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 15 May 2008, 02:36 PM
Hi Saurabh,

You can check if the RadDockingManager is present on the MOSS page and add it to the controls collection of the web part if it is not present. You can check the existence of the RadDockingManager on the page with the GetCurrentRadDockingManager method of the RadDockingManager class, e. g.:
if (RadDockingManager.GetCurrentRadDockingManager(this.Page) == null)  
{  
    RadDockingManager manager1 = new RadDockingManager();  
    manager1.ID = "DockingManger1";  
    this.Controls.Add(manager1);  

If you need further assistance, do contact us again.

All the best,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Sharepoint Integration
Asked by
Pravat
Top achievements
Rank 1
Answers by
Sophy
Telerik team
Share this question
or