protected void Page_Init(object sender, EventArgs e)
        {
            jsonSerializer=new JavaScriptSerializer();
            TreeDefinition contentTree = TreeDefinitionCollection.Instance.Single(x => x.Tree.Alias.ToUpper() == "CONTENT");

            TreeDefinition filteredContentTree = new TreeDefinition(typeof(ContentPickerTree),
                                                         new umbraco.BusinessLogic.ApplicationTree(true, false, 0,
                                                                   contentTree.Tree.ApplicationAlias,
                                                                   "ContentPickerTree",
                                                                   contentTree.Tree.Title,
                                                                   contentTree.Tree.IconClosed,
                                                                   contentTree.Tree.IconOpened,
                                                                   "umbraco.editorControls",
                                                                   "ContentPicker_FE.ContentPickerTree",
                                                                   contentTree.Tree.Action),
                                                         contentTree.App);

            TreeDefinitionCollection.Instance.Add(filteredContentTree);

            CustomTreeControl treeControl = new CustomTreeControl();
            treeControl.StartNodeID=1937;//does not work
            treeControl.IsDialog=true;
            treeControl.DialogMode=TreeDialogModes.id;
            treeControl.TreeType="ContentPickerTree";
            treeControl.ShowContextMenu=false;

            treePickerDiv.Controls.AddAt(0, treeControl);

            //passing in the saved options to the page for use by jQuery
            ContentPicker_Options savedOptions = jsonSerializer.Deserialize<ContentPicker_Options>(HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies["contentPicker"].Value));

            //Log.Add(LogTypes.Debug, 0, "cp=>"+savedOptions.jsPath);

            //add custom js/css if defined
            if (savedOptions.cssPath != "")
            {
                string customCSS = string.Format("<link href=\"{0}\" type=\"text/css\" rel=\"stylesheet\" />", savedOptions.cssPath);

                HtmlGenericControl link = new HtmlGenericControl();
                link.InnerHtml = customCSS;
                head.Controls.Add(link);
            }

            if (savedOptions.jsPath != "")
            {
                string customJS = string.Format("<script src=\"{0}\" ></script>", savedOptions.jsPath);
                HtmlGenericControl script= new HtmlGenericControl();
                script.InnerHtml = customJS;
                head.Controls.Add(script);
            }
            treePickerDiv.Attributes["allowMultiple"] = savedOptions.allowMultiple.ToString().ToLower();
        }
Пример #2
0
		/// <summary>
		/// Creates the child controls for this control
		/// </summary>
		protected override void CreateChildControls()
		{
			base.CreateChildControls();

			EnsureChildControls();

			//create the tree control
			TreePickerControl = new CustomTreeControl
				{
					ID = "TreePicker",
					IsDialog = true,
					ShowContextMenu = false,
					DialogMode = TreeDialogModes.id,
					Height = Unit.Pixel(ControlHeight),
					StartNodeID = StartNodeId
				};

			//create the hidden field
			PickedValue = new HiddenField { ID = "PickedValue" };

			//create the right column
			RightColumn = new HtmlGenericControl("div") { ID = "RightColumn" };
			RightColumn.Attributes.Add("class", "right propertypane");

			//create the repeater
			SelectedValues = new Repeater
				{
					//EnableViewState = false,
					ID = "SelectedValues",
					ItemTemplate = new SelectedItemsTemplate()
				};

			SelectedValues.ItemDataBound += SelectedValues_ItemDataBound;

			//add the repeater to the right column
			RightColumn.Controls.Add(SelectedValues);

			MinItemsValidator = new CustomValidator()
									{
										ID = "MinItemsValidator",
										ErrorMessage =
											string.Format(MNTPResources.Val_MinItemsInvalid, MinNodeCount)
									};
			MinItemsValidator.ServerValidate += new ServerValidateEventHandler(MinItemsValidator_ServerValidate);

			//add the controls
			this.Controls.Add(MinItemsValidator);
			this.Controls.Add(TreePickerControl);
			this.Controls.Add(PickedValue);
			this.Controls.Add(RightColumn);
		}