コード例 #1
0
    /// <summary>
    /// Creates data structure containing properties which are needed to perform mass action. This mainly includes
    /// filter values (so correct where condition can be produced), URLs of the opened dialogs, etc.
    /// </summary>
    /// <returns>Mass actions parameters</returns>
    private DocumentListMassActionsParameters GetMassActionsParameters()
    {
        return(new DocumentListMassActionsParameters
        {
            ShowAllLevels = ShowAllLevels,
            ClassID = ClassID,
            CurrentWhereCondition = CurrentWhereCondition,
            Identifier = Identifier,
            Node = Node,
            RequiresDialog = RequiresDialog,
            WOpenerNodeID = WOpenerNodeID,
            ArchiveReturnUrl = ArchiveReturnUrl,
            DeleteReturnUrl = DeleteReturnUrl,
            GetCopyMoveLinkBaseActionUrl = actionCode =>
            {
                Config.CustomFormatCode = actionCode.ToLowerCSafe();
                if (actionCode.Equals("Link", StringComparison.OrdinalIgnoreCase))
                {
                    Config.ContentSites = AvailableSitesEnum.OnlyCurrentSite;
                }

                if (!string.IsNullOrEmpty(CopyMoveLinkStartingPath))
                {
                    Config.ContentStartingPath = CopyMoveLinkStartingPath;
                }

                return CMSDialogHelper.GetDialogUrl(Config, false, null, false);
            },
            TranslateReturnUrl = TranslateReturnUrl,
            PublishReturnUrl = PublishReturnUrl,
        });
    }
コード例 #2
0
    /// <summary>
    /// Creates data structure containing properties which are needed to perform mass action. This mainly includes
    /// filter values (so correct where condition can be produced), URLs of the opened dialogs, etc.
    /// </summary>
    /// <returns>Mass actions parameters</returns>
    private DocumentListMassActionsParameters GetMassActionsParameters()
    {
        return(new DocumentListMassActionsParameters
        {
            ShowAllLevels = ShowAllLevels,
            ClassID = ClassID,
            CurrentWhereCondition = CurrentWhereCondition,
            Identifier = Identifier,
            Node = Node,
            RequiresDialog = RequiresDialog,
            WOpenerNodeID = WOpenerNodeID,
            ArchiveReturnUrl = ArchiveReturnUrl,
            DeleteReturnUrl = DeleteReturnUrl,
            GetCopyMoveLinkBaseActionUrl = actionCode =>
            {
                Config.CustomFormatCode = actionCode.ToLowerCSafe();

                if (!string.IsNullOrEmpty(CopyMoveLinkStartingPath))
                {
                    Config.ContentStartingPath = Server.UrlEncode(CopyMoveLinkStartingPath);
                }

                return CMSDialogHelper.GetDialogUrl(Config, false, false, null, false);
            },
            TranslateReturnUrl = TranslateReturnUrl,
            PublishReturnUrl = PublishReturnUrl,
        });
    }
コード例 #3
0
    /// <summary>
    /// Returns correct URL of the select path dialog.
    /// </summary>
    /// <param name="textboxId">Client ID of the textbox where result should be returned.</param>
    private string GetDocumentDialogUrl(string textboxId)
    {
        var config = new DialogConfiguration
        {
            HideLibraries       = true,
            HideAnchor          = true,
            HideAttachments     = true,
            HideContent         = false,
            HideEmail           = true,
            HideWeb             = true,
            EditorClientID      = textboxId,
            ContentSelectedSite = SiteContext.CurrentSiteName,
            OutputFormat        = OutputFormatEnum.Custom,
            CustomFormatCode    = "selectpath",
            SelectableContent   = SelectableContentEnum.AllContent,
            SelectablePageTypes = SelectablePageTypeEnum.Standard,
            ContentSites        = AvailableSitesEnum.OnlyCurrentSite
        };

        string url = CMSDialogHelper.GetDialogUrl(config, false, false, null, false);

        url = URLHelper.RemoveParameterFromUrl(url, "hash");
        url = URLHelper.AddParameterToUrl(url, "selectionmode", "single");
        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));

        return(url);
    }
コード例 #4
0
    /// <summary>
    /// Returns Javascript used for invoking 'add related document' dialog.
    /// </summary>
    public string GetAddRelatedDocumentScript()
    {
        string postbackArgument;

        if (!AllowSwitchSides && !string.IsNullOrEmpty(RelationshipName))
        {
            postbackArgument = "insertfromselectdocument";

            // Register javascript 'postback' function
            string script = "function RefreshRelatedPanel(elementId) { if (elementId != null) { __doPostBack(elementId, '" + postbackArgument + "'); } } \n";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshRelatedPanel", ScriptHelper.GetScript(script));

            // Dialog 'Select document'
            Config.EditorClientID = pnlUpdate.ClientID + ";" + hdnSelectedNodeId.ClientID;

            // Set dialog starting path
            if (!string.IsNullOrEmpty(StartingPath))
            {
                Config.ContentStartingPath = StartingPath;
            }

            string url = CMSDialogHelper.GetDialogUrl(Config, false, null, false);

            return(string.Format("modalDialog('{0}', 'contentselectnode', '90%', '85%');", url));
        }
        else
        {
            postbackArgument = "insert";

            // Register javascript 'postback' function
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshUpdatePanel_" + ClientID, ScriptHelper.GetScript(
                                                       "function RefreshUpdatePanel_" + ClientID + "(){ " + Page.ClientScript.GetPostBackEventReference(pnlUpdate, postbackArgument) + "; } \n"));

            // Dialog 'Add related document'
            string query = "?nodeid=" + TreeNode.NodeID;
            query = URLHelper.AddUrlParameter(query, "defaultside", DefaultSide.ToString());
            query = URLHelper.AddUrlParameter(query, "allowswitchsides", AllowSwitchSides.ToString());
            query = URLHelper.AddUrlParameter(query, "relationshipname", RelationshipName);
            query = URLHelper.AddUrlParameter(query, "externalControlID", ClientID);
            query = URLHelper.AddUrlParameter(query, "startingpath", StartingPath ?? "");

            query = query.Replace("%", "%25").Replace("/", "%2F");

            query = URLHelper.AddUrlParameter(query, "hash", QueryHelper.GetHash(query));

            string url;
            if (IsLiveSite)
            {
                url = ResolveUrl("~/CMSFormControls/LiveSelectors/RelatedDocuments.aspx" + query);
            }
            else
            {
                url = ResolveUrl("~/CMSFormControls/Selectors/RelatedDocuments.aspx" + query);
            }

            return(string.Format("modalDialog('{0}', 'AddRelatedDocument', '900', '315');", url));
        }
    }
コード例 #5
0
    /// <summary>
    /// Returns Correct URL of the path selection dialog.
    /// </summary>
    private string GetSelectionDialogUrl()
    {
        string url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false);

        url = URLHelper.RemoveParameterFromUrl(url, "hash");
        url = URLHelper.AddParameterToUrl(url, "selectionmode", "single");
        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));
        url = URLHelper.EncodeQueryString(url);
        return(url);
    }
コード例 #6
0
    /// <summary>
    /// Returns Correct URL of the link dialog.
    /// </summary>
    /// <param name="nodeId">ID Of the node to be copied or moved</param>
    private string GetLinkDialogUrl(int nodeId)
    {
        DialogConfiguration config = ProductUIHelper.GetProductDialogConfig("linkdoc", null);
        string url = CMSDialogHelper.GetDialogUrl(config, false, false, null, false);

        // Prepare url for link dialog
        url = URLHelper.RemoveParameterFromUrl(url, "hash");
        url = URLHelper.AddParameterToUrl(url, "sourcenodeids", nodeId.ToString());
        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));

        return(url);
    }
コード例 #7
0
    /// <summary>
    /// Returns Correct URL of the copy or move dialog.
    /// </summary>
    /// <param name="nodeId">ID Of the node to be copied or moved</param>
    /// <param name="CurrentAction">Action which should be performed</param>
    private string GetDialogUrl(int nodeId, Action CurrentAction)
    {
        Config.CustomFormatCode = CurrentAction.ToString().ToLower();
        string url = CMSDialogHelper.GetDialogUrl(Config, false, false, null, false);

        url = URLHelper.RemoveParameterFromUrl(url, "hash");
        url = URLHelper.AddParameterToUrl(url, "sourcenodeids", nodeId.ToString());
        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));
        url = URLHelper.EncodeQueryString(url);

        return(url);
    }
コード例 #8
0
ファイル: New.aspx.cs プロジェクト: kudutest2/Kentico
    /// <summary>
    /// Returns Correct URL of the copy or move dialog.
    /// </summary>
    /// <param name="currentNodeId">ID Of the node to be copied or moved</param>
    private string GetLinkDialogUrl(int currentNodeId)
    {
        Config.CustomFormatCode = "linkdoc";
        string url = CMSDialogHelper.GetDialogUrl(Config, false, false, null, false);

        // Prepare url for link dialog
        url = URLHelper.RemoveParameterFromUrl(url, "hash");
        url = URLHelper.AddParameterToUrl(url, "sourcenodeids", currentNodeId.ToString());
        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));
        url = URLHelper.EncodeQueryString(url);

        return(url);
    }
コード例 #9
0
    /// <summary>
    /// Returns Correct URL of the path selection dialog.
    /// </summary>
    private string GetSelectionDialogUrl()
    {
        string url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false);

        url = URLHelper.RemoveParameterFromUrl(url, "hash");

        // Set single path mode
        if (SinglePathMode)
        {
            url = URLHelper.AddParameterToUrl(url, "selectionmode", "single");
        }

        // Recreate correct hash string to secure input
        string query = CMSDialogHelper.EncodeQueryString(URLHelper.GetQuery(url));

        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(query));

        return(url);
    }
コード例 #10
0
ファイル: SelectPath.ascx.cs プロジェクト: kudutest2/Kentico
    /// <summary>
    /// Returns Correct URL of the copy or move dialog.
    /// </summary>
    private string GetDialogUrl()
    {
        string url = CMSDialogHelper.GetDialogUrl(this.Config, this.IsLiveSite, false, null, false);

        return(url);
    }
コード例 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);

        DefaultSide                = QueryHelper.GetBoolean("defaultside", DefaultSide);
        AllowSwitchSides           = QueryHelper.GetBoolean("allowswitchsides", AllowSwitchSides);
        RelationshipName           = QueryHelper.GetString("relationshipname", RelationshipName);
        Config.ContentStartingPath = QueryHelper.GetString("startingpath", Config.ContentStartingPath);

        relNameSelector.IsLiveSite = false;
        btnSwitchSides.Visible     = AllowSwitchSides;
        btnOk.Visible = ShowButtons;

        // Initialize dialog scripts
        Config.EditorClientID = txtLeftNode.ClientID + ";" + hdnSelectedNodeId.ClientID;
        string url = CMSDialogHelper.GetDialogUrl(Config, false, null, false);

        btnLeftNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;";

        Config.EditorClientID = txtRightNode.ClientID + ";" + hdnSelectedNodeId.ClientID;
        url = CMSDialogHelper.GetDialogUrl(Config, false, null, false);
        btnRightNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;";

        if (TreeNode != null)
        {
            currentNodeId = TreeNode.NodeID;

            var documentName = HTMLHelper.HTMLEncode(TreeNode.GetDocumentName());
            // Check modify permissions
            if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
            {
                Enabled = false;
                ShowInformation(String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), documentName));
            }

            lblRightNode.Text = lblLeftNode.Text = documentName;
        }
        else
        {
            Enabled = false;
        }

        // All relationship names for current site
        if (string.IsNullOrEmpty(RelationshipName))
        {
            relNameSelector.Visible = true;
            lblRelName.Visible      = false;
        }
        else
        {
            relationshipNameInfo = RelationshipNameInfo.Provider.Get(RelationshipName);
            if (relationshipNameInfo != null)
            {
                lblRelName.Text = relationshipNameInfo.RelationshipDisplayName;
            }

            relNameSelector.Visible = false;
            lblRelName.Visible      = true;
        }

        // Register switching js
        if (btnSwitchSides.Enabled && btnSwitchSides.Visible)
        {
            RegisterScript();
        }

        if (!RequestHelper.IsPostBack())
        {
            hdnCurrentOnLeft.Value = !DefaultSide ? "true" : "false";
        }

        bool isLeftSide = ValidationHelper.GetBoolean(hdnCurrentOnLeft.Value, false);

        // Left side
        if (isLeftSide)
        {
            pnlLeftSelectedNode.AddCssClass("hidden");
            lblRightNode.AddCssClass("hidden");

            pnlRightSelectedNode.RemoveCssClass("hidden");
            lblLeftNode.RemoveCssClass("hidden");
        }
        // Right side
        else
        {
            lblLeftNode.AddCssClass("hidden");
            pnlRightSelectedNode.AddCssClass("hidden");

            pnlLeftSelectedNode.RemoveCssClass("hidden");
            lblRightNode.RemoveCssClass("hidden");
        }

        // Clear breadcrumbs suffix (we don't want it when creating new object)
        UIHelper.SetBreadcrumbsSuffix("");
    }
コード例 #12
0
    /// <summary>
    /// Returns Correct URL dialog.
    /// </summary>
    private string GetDialogUrl()
    {
        string url = CMSDialogHelper.GetDialogUrl(Config, true, false, null, false);

        return(url);
    }
コード例 #13
0
    public string GetCallbackResult()
    {
        string    returnUrl  = string.Empty;
        Hashtable parameters = new Hashtable();

        switch (callbackAction)
        {
        case Action.Copy:
        case Action.Move:
        case Action.Link:

            // Get default dialog URL
            Config.CustomFormatCode = callbackAction.ToString().ToLower();
            returnUrl = CMSDialogHelper.GetDialogUrl(Config, false, false, null, false);

            // Adjust URL to our needs
            returnUrl = URLHelper.RemoveParameterFromUrl(returnUrl, "hash");
            returnUrl = URLHelper.AddParameterToUrl(returnUrl, "multiple", "true");

            // Process parameters
            if (!string.IsNullOrEmpty(urlParameter))
            {
                returnUrl = URLHelper.AddParameterToUrl(returnUrl, "sourcenodeids", urlParameter);
            }
            else if (!string.IsNullOrEmpty(aliasPath))
            {
                parameters["parentalias"] = aliasPath;
            }

            if (!string.IsNullOrEmpty(CurrentWhereCondition))
            {
                parameters["where"] = CurrentWhereCondition;
            }

            break;

        case Action.Delete:
            returnUrl = "../Delete.aspx?multiple=true";

            // Process parameters
            if (allSelected)
            {
                if (!string.IsNullOrEmpty(aliasPath))
                {
                    parameters["parentaliaspath"] = aliasPath;
                }
                if (!string.IsNullOrEmpty(CurrentWhereCondition))
                {
                    parameters["where"] = CurrentWhereCondition;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(urlParameter))
                {
                    returnUrl = URLHelper.AddParameterToUrl(returnUrl, "nodeId", urlParameter);
                }
            }
            break;

        case Action.Archive:
        case Action.Publish:
            returnUrl = "../PublishArchive.aspx?multiple=true";
            returnUrl = URLHelper.AddParameterToUrl(returnUrl, "action", callbackAction.ToString());

            // Process parameters
            if (allSelected)
            {
                if (!string.IsNullOrEmpty(aliasPath))
                {
                    parameters["parentaliaspath"] = aliasPath;
                }
                if (!string.IsNullOrEmpty(CurrentWhereCondition))
                {
                    parameters["where"] = CurrentWhereCondition;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(urlParameter))
                {
                    parameters["nodeids"] = urlParameter;
                }
            }
            break;
        }

        // Store parameters to window helper
        WindowHelper.Add(Identificator, parameters);

        // Add parameters identifier and hash, encode query string
        returnUrl = URLHelper.AddParameterToUrl(returnUrl, "params", Identificator);
        returnUrl = ResolveUrl(returnUrl);
        returnUrl = URLHelper.AddParameterToUrl(returnUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(returnUrl)));

        return(returnUrl);
    }
コード例 #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);

        DefaultSide      = QueryHelper.GetBoolean("defaultside", DefaultSide);
        AllowSwitchSides = QueryHelper.GetBoolean("allowswitchsides", AllowSwitchSides);
        RelationshipName = QueryHelper.GetString("relationshipname", RelationshipName);

        relNameSelector.IsLiveSite = false;
        btnSwitchSides.Visible     = AllowSwitchSides;
        btnOk.Visible = ShowButtons;

        // Initialize dialog scripts
        Config.EditorClientID = txtLeftNode.ClientID + ";" + hdnSelectedNodeId.ClientID;
        string url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false);

        btnLeftNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;";

        Config.EditorClientID = txtRightNode.ClientID + ";" + hdnSelectedNodeId.ClientID;
        url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false);
        btnRightNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;";

        leftCell.Text   = GetString("Relationship.leftSideDoc");
        middleCell.Text = GetString("Relationship.RelationshipName");
        rightCell.Text  = GetString("Relationship.rightSideDoc");

        if (TreeNode != null)
        {
            currentNodeId = TreeNode.NodeID;

            // Check modify permissions
            if (CMSContext.CurrentUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
            {
                Enabled         = false;
                lblInfo.Visible = true;
                lblInfo.Text    = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), TreeNode.NodeAliasPath);
            }

            string nodeDocumentName = TreeNode.DocumentName;
            lblRightNode.Text = lblLeftNode.Text = (string.IsNullOrEmpty(nodeDocumentName)) ? "/" : HTMLHelper.HTMLEncode(nodeDocumentName);
        }
        else
        {
            Enabled = false;
        }

        // All relationship names for current site
        if (string.IsNullOrEmpty(RelationshipName))
        {
            relNameSelector.Visible = true;
            lblRelName.Visible      = false;
        }
        else
        {
            relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName);
            if (relationshipNameInfo != null)
            {
                lblRelName.Text = relationshipNameInfo.RelationshipDisplayName;
            }

            relNameSelector.Visible = false;
            lblRelName.Visible      = true;
        }

        // Register switching js
        if (btnSwitchSides.Enabled)
        {
            RegisterScript();
        }

        if (!RequestHelper.IsPostBack())
        {
            hdnCurrentOnLeft.Value = !DefaultSide ? "true" : "false";
        }

        bool isLeftSide = ValidationHelper.GetBoolean(hdnCurrentOnLeft.Value, false);

        // Left side
        if (isLeftSide)
        {
            pnlLeftCurrentNode.Style.Add("display", "block");
            pnlLeftSelectedNode.Style.Add("display", "none");
            pnlLeftSelectButton.Style.Add("display", "none");
            pnlRightCurrentNode.Style.Add("display", "none");
            pnlRightSelectedNode.Style.Add("display", "block");
            pnlRightSelectButton.Style.Add("display", "block");
        }
        // Right side
        else
        {
            pnlLeftCurrentNode.Style.Add("display", "none");
            pnlLeftSelectedNode.Style.Add("display", "block");
            pnlLeftSelectButton.Style.Add("display", "block");
            pnlRightCurrentNode.Style.Add("display", "block");
            pnlRightSelectedNode.Style.Add("display", "none");
            pnlRightSelectButton.Style.Add("display", "none");
        }
    }
コード例 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            UniGridRelationship.StopProcessing = StopProcessing;
        }
        else
        {
            // Set tree node from Form object
            if ((TreeNode == null) && (Form != null) && (Form.EditedObject != null))
            {
                TreeNode node = Form.EditedObject as TreeNode;
                if ((node != null) && (Form.Mode == FormModeEnum.Update))
                {
                    TreeNode = node;
                }
                else
                {
                    lblError.Text = GetString("relationship.editdocumenterror");
                }
            }

            if (TreeNode != null)
            {
                // Settings
                RelationshipName = ValidationHelper.GetString(GetValue("RelationshipName"), RelationshipName);
                AllowSwitchSides = ValidationHelper.GetBoolean(GetValue("AllowSwitchSides"), AllowSwitchSides);
                DefaultSide      = ValidationHelper.GetBoolean(GetValue("DefaultSide"), DefaultSide);

                // Set unigrid
                UniGridRelationship.Columns              = "LeftNodeID, RightNodeID, RelationshipNameID, LeftNodeName, RightNodeName, RelationshipDisplayName";
                UniGridRelationship.OnExternalDataBound += UniGridRelationship_OnExternalDataBound;
                UniGridRelationship.OnBeforeDataReload  += UniGridRelationship_OnBeforeDataReload;
                UniGridRelationship.OnAction            += UniGridRelationship_OnAction;
                UniGridRelationship.ZeroRowsText         = GetString("general.nodatafound");

                int  nodeId = TreeNode.NodeID;
                bool oneRelationshipName = !string.IsNullOrEmpty(RelationshipName);
                string where = null;
                if (oneRelationshipName)
                {
                    where = SqlHelperClass.AddWhereCondition(where, "RelationshipName = N'" + SqlHelperClass.GetSafeQueryString(RelationshipName, false) + "'");
                }

                // Switch sides is disabled
                if (!AllowSwitchSides)
                {
                    if (DefaultSide)
                    {
                        where = SqlHelperClass.AddWhereCondition(where, "RightNodeID = " + nodeId);
                    }
                    else
                    {
                        where = SqlHelperClass.AddWhereCondition(where, "LeftNodeID = " + nodeId);
                    }
                }
                else
                {
                    where = SqlHelperClass.AddWhereCondition(where, "(LeftNodeID = " + nodeId + ") OR (RightNodeID = " + nodeId + ")");
                }

                UniGridRelationship.WhereCondition = where;

                if (ShowAddRelation)
                {
                    string postbackArgument = null;
                    if (!AllowSwitchSides && !string.IsNullOrEmpty(RelationshipName))
                    {
                        postbackArgument = "insertfromselectdocument";

                        // Register javascript 'postback' function
                        string script = "function RefreshRelatedPanel(elementId) { if (elementId != null) { __doPostBack(elementId, '" + postbackArgument + "'); } } \n";
                        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshRelatedPanel", ScriptHelper.GetScript(script));

                        // Dialog 'Select document'
                        Config.EditorClientID = pnlUpdate.ClientID + ";" + hdnSelectedNodeId.ClientID;
                        string url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false);
                        lnkNewRelationship.Style.Add("cursor", "pointer");
                        lnkNewRelationship.Style.Add("text-decoration", "underline");
                        lnkNewRelationship.Attributes.Add("onclick", "modalDialog('" + url + "', 'contentselectnode', '90%', '85%');");
                    }
                    else
                    {
                        postbackArgument = "insert";

                        // Register javascript 'postback' function
                        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshUpdatePanel_" + ClientID, ScriptHelper.GetScript(
                                                                   "function RefreshUpdatePanel_" + ClientID + "(){ " + Page.ClientScript.GetPostBackEventReference(pnlUpdate, postbackArgument) + "; } \n"));

                        // Dialog 'Add related document'
                        string query = "?nodeid=" + nodeId.ToString();
                        query = URLHelper.AddUrlParameter(query, "defaultside", DefaultSide.ToString());
                        query = URLHelper.AddUrlParameter(query, "allowswitchsides", AllowSwitchSides.ToString());
                        query = URLHelper.AddUrlParameter(query, "relationshipname", RelationshipName);
                        query = URLHelper.AddUrlParameter(query, "externalControlID", ClientID);
                        query = URLHelper.AddUrlParameter(query, "hash", QueryHelper.GetHash(query));

                        string url = null;
                        if (IsLiveSite)
                        {
                            url = ResolveUrl("~/CMSFormControls/LiveSelectors/RelatedDocuments.aspx" + query);
                        }
                        else
                        {
                            url = ResolveUrl("~/CMSFormControls/Selectors/RelatedDocuments.aspx" + query);
                        }

                        // Initialize controls
                        lnkNewRelationship.NavigateUrl = url;
                        lnkNewRelationship.Attributes.Add("onclick", "modalDialog('" + url + "', 'AddRelatedDocument', '900', '300'); return false;");
                    }


                    imgNewRelationship.ImageUrl         = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationship.png");
                    imgNewRelationship.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationshipdisabled.png");
                }
                else
                {
                    pnlNewLink.Visible = false;
                }
            }
            else
            {
                UniGridRelationship.StopProcessing = true;
                UniGridRelationship.Visible        = false;
                pnlNewLink.Visible = false;
            }

            if (RequestHelper.IsPostBack())
            {
                string target = Request["__EVENTTARGET"];
                if ((target == pnlUpdate.ClientID) || (target == pnlUpdate.UniqueID))
                {
                    string action = Request["__EVENTARGUMENT"];

                    if (!string.IsNullOrEmpty(action))
                    {
                        switch (action.ToLower())
                        {
                        // Insert from 'Add related document' dialog
                        case "insert":
                            lblInfo.Text = GetString("relationship.wasadded");
                            break;

                        // Insert from 'Select document' dialog
                        case "insertfromselectdocument":
                            SaveRelationship();
                            break;

                        // Nothing
                        default:
                            break;
                        }
                    }
                }
            }

            bool inserted = QueryHelper.GetBoolean("inserted", false);
            if (inserted)
            {
                lblInfo.Text = GetString("relationship.wasadded");
            }
        }
    }