RadDockingManager In MOSS Web part

2 posts, 0 answers
  1. Pravat
    Pravat avatar
    13 posts
    Member since:
    Aug 2007

    Posted 13 May 2008 Link to this post

    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:
    1 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MYItem.ascx.cs" Inherits="MY.UserControls.MYItem" %> 
    2 <%@ Register Assembly="RadDock.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %> 
    3 <%@ Register TagPrefix="radcb" Namespace="Telerik.WebControls" Assembly="RadComboBox.NET2" %> 
    4  
    5  
    6 <rad:RadDockingManager ID="RadDockingManager1" runat="server" /> 
    7  
    8 <rad:RadDockingZone ID="RadDockingZone1" runat="server"
    9     <rad:RadDockableObject ID="RadDockableObject1" runat="server"
    10         <ContentTemplate> 
    11             <asp:Panel ID="PanelConfig" runat="server" Visible="false"
    12                 <radcb:radcombobox MarkFirstMatch="true" AllowCustomText="false"  Sort="Descending" id="RadComboBox1" Skin="Default" Width="300px" AutoPostBack="false" RadComboBoxImagePosition="Right" Height="140px" Runat="server"></radcb:radcombobox> 
    13                 <asp:Button id="Button1" runat="server" Text="Select" OnClick="Button1_Click" CssClass="CommandButton"></asp:Button> 
    14                 <br /><br /> 
    15             </asp:Panel> 
    16             <iframe id="iframeGrid" height="417px" width="655px" frameborder="0" scrolling="yes" runat="server" src="~/utils/pleasewait.aspx"></iframe> 
    17         </ContentTemplate> 
    18         <Commands> 
    19             <rad:RadDockableObjectCommand AutoPostBack="true" Image="../images/icon_edit.gif" Name="edit"></rad:RadDockableObjectCommand> 
    20             <rad:RadDockableObjectCommand AutoPostBack="true" Image="../images/icon_clsdfold.gif" Name="closeedit" /> 
    21         </Commands> 
    22     </rad:RadDockableObject> 
    23 </rad:RadDockingZone> 
    24  

    The code for the web part that contains this user control is as follows:
    1 using System; 
    2 using System.Runtime.InteropServices; 
    3 using System.Web.UI; 
    4 using System.Web.UI.WebControls.WebParts; 
    5 using System.Xml.Serialization; 
    6  
    7 using Microsoft.SharePoint; 
    8 using Microsoft.SharePoint.WebControls; 
    9 using Microsoft.SharePoint.WebPartPages; 
    10 using System.ComponentModel; 
    11  
    12 namespace MY.Parts 
    13
    14     [DefaultProperty("Text"), 
    15 ToolboxData("<{0}:MYWP runat=server></{0}:MYWP>"), 
    16        XmlRoot(Namespace = "MY.Parts")] 
    17     public class MYWP : Microsoft.SharePoint.WebPartPages.WebPart 
    18     { 
    19  
    20         private const string defaultText = ""
    21         private string _userControl = defaultText;         
    22         private Control _control = null
    23         private ScriptManager _AjaxManager; 
    24  
    25  
    26         [Browsable(true), 
    27             Category("User Control"), 
    28           DefaultValue(defaultText), 
    29             WebPartStorage(Storage.Personal), 
    30             FriendlyName("User Control (.ascx)"), 
    31             Description("Path to the User Control (.ascx)")] 
    32         public string UserControl 
    33         { 
    34             get 
    35             { 
    36                 return _userControl; 
    37             } 
    38  
    39             set 
    40             { 
    41                 _userControl = value
    42             } 
    43         }         
    44  
    45         public MYWP() 
    46         { 
    47             this.ExportMode = WebPartExportMode.All; 
    48         } 
    49  
    50         protected override void CreateChildControls() 
    51         { 
    52             base.CreateChildControls(); 
    53  
    54             try 
    55             { 
    56                 if ((this._control == null) && (this.Page != null)) 
    57                 { 
    58                     try 
    59                     { 
    60                         if (_userControl != defaultText) 
    61                         { 
    62                             if ((this._userControl != "") && (this._userControl.IndexOf("~") != -1)) 
    63                             { 
    64                                 thisthis._control = this.Page.LoadControl(this._userControl);                                 
    65                             } 
    66                         } 
    67                         else 
    68                         { 
    69                             _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)); 
    70                         } 
    71                     } 
    72                     catch (Exception exception) 
    73                     { 
    74                         this._control = new LiteralControl(string.Format("<b>Error:</b> unable to load {0}<br /><b>Details:</b> {1}", this._userControl, exception.Message)); 
    75                     } 
    76                 } 
    77             } 
    78             catch (System.Exception ex) 
    79             { 
    80                 _control = new LiteralControl(string.Format("<b>Error:</b> unable to load {0}<br /><b>Details:</b> {1}", _userControl, ex.Message)); 
    81             } 
    82  
    83             if (_control != null) 
    84             { 
    85                 // Add to the Controls collection to support postback 
    86                 this.Controls.Add(_control); 
    87             } 
    88         } 
    89  
    90         protected override void RenderWebPart(HtmlTextWriter output) 
    91         { 
    92             EnsureChildControls(); 
    93             if (_control != null) 
    94             { 
    95                 _control.RenderControl(output); 
    96             } 
    97         } 
    98  
    99         protected override void OnInit(EventArgs e) 
    100         { 
    101             try 
    102             { 
    103                 base.OnInit(e); 
    104                 this._AjaxManager = ScriptManager.GetCurrent(this.Page); 
    105                 if (this._AjaxManager == null) 
    106                 { 
    107                     this._AjaxManager = new ScriptManager(); 
    108                     this._AjaxManager.EnablePartialRendering = true
    109                     this._AjaxManager.EnableScriptLocalization = true
    110                     this.Page.ClientScript.RegisterStartupScript(typeof(MYWP), this.ID, "_spOriginalFormAction = document.forms[0].action;", true); 
    111                     if (this.Page.Form != null) 
    112                     { 
    113                         string str = this.Page.Form.Attributes["onsubmit"]; 
    114                         if (!string.IsNullOrEmpty(str) && (str == "return _spFormOnSubmitWrapper();")) 
    115                         { 
    116                             this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();"; 
    117                         } 
    118                         try 
    119                         { 
    120                             this.Page.Form.Controls.AddAt(0, this._AjaxManager); 
    121                         } 
    122                         catch (Exception ex) 
    123                         { 
    124                             this.Controls.AddAt(0, this._AjaxManager); 
    125                         } 
    126                     } 
    127                 } 
    128             } 
    129             catch (Exception ex) 
    130             { 
    131             } 
    132         } 
    133  
    134         [WebPartStorage(Storage.None)] 
    135         public ScriptManager AjaxManager 
    136         { 
    137             get 
    138             { 
    139                 return this._AjaxManager; 
    140             } 
    141             set 
    142             { 
    143                 this._AjaxManager = value
    144             } 
    145         } 
    146  
    147     } 
    148
    149  

    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


  2. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 15 May 2008 Link to this post

    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

Back to Top