/// <summary> /// PreRender event handler. /// </summary> protected void Page_PreRender(object sender, EventArgs e) { if ((Node != null) && (TagGroupSelector != null)) { bool noneSelected = ValidationHelper.GetInteger(TagGroupSelector.Value, 0) == 0; object val; inheritedValues.TryGetValue("DocumentTagGroupID", out val); int parentValue = ValidationHelper.GetInteger(val, 0); // Allow empty value in selector if node has no tag group selected and parent tag group also isn't set TagGroupSelector.SetValue("AllowEmpty", noneSelected || ((Node.DocumentTagGroupID == 0) && (parentValue == 0))); if (!TagGroupSelector.HasData) { // Hide tag module controls and show information if no tag group exists Control.MessagesPlaceHolder.ShowInformation(ResHelper.GetString("PageProperties.TagsInfo")); Control.FieldsToHide.Add("DocumentTagGroupID"); Control.FieldsToHide.Add("DocumentTagGroupIDInherit"); Control.FieldsToHide.Add("DocumentTags"); } else { Control.FieldControls["DocumentTags"].Enabled = !noneSelected; if (noneSelected) { // Clear tags if no tag group selected Control.FieldControls["DocumentTags"].Text = String.Empty; } } } }
/// <summary> /// PreRender event handler. /// </summary> protected void Page_PreRender(object sender, EventArgs e) { if ((Node == null) || (TagGroupSelector == null)) { return; } bool noneSelected = ValidationHelper.GetInteger(TagGroupSelector.Value, 0) == 0; object val; inheritedValues.TryGetValue("DocumentTagGroupID", out val); int parentValue = ValidationHelper.GetInteger(val, 0); // Allow empty value in selector if node has no tag group selected and parent tag group also isn't set TagGroupSelector.SetValue("AllowEmpty", noneSelected || ((Node.DocumentTagGroupID == 0) && (parentValue == 0))); // Get all groups from original page site ID TagGroupSelector.SetValue("WhereCondition", "[TagGroupSiteID] = " + Node.OriginalNodeSiteID); if (!TagGroupSelector.HasData) { // Hide tag module controls and show information if no tag group exists Control.MessagesPlaceHolder.ShowInformation(ResHelper.GetString("PageProperties.TagsInfo")); Control.FieldsToHide.Add("DocumentTagGroupID"); Control.FieldsToHide.Add("DocumentTagGroupIDInherit"); Control.FieldsToHide.Add("DocumentTags"); var lblNoTags = ControlsHelper.GetChildControl(Control, typeof(LocalizedLabel), "lblNoTags") as LocalizedLabel; lblNoTags.Visible = true; } else { Control.FieldControls["DocumentTags"].Enabled = !noneSelected; if (noneSelected) { // Clear tags if no tag group selected Control.FieldControls["DocumentTags"].Text = String.Empty; } } }