private static void AddHelpLink( Panel parentControl, CProfilePropertyDefinition propertyDefinition) { Literal litSpace = new Literal(); litSpace.Text = " "; parentControl.Controls.Add(litSpace); CHelpLink helpLinkButton = new CHelpLink(); helpLinkButton.HelpKey = "profile-" + propertyDefinition.Name.ToLower() + "-help"; parentControl.Controls.Add(helpLinkButton); litSpace = new Literal(); litSpace.Text = " "; parentControl.Controls.Add(litSpace); }
private void AddSettingControl(CustomModuleSetting s) { if (s.SettingName == "WebPartModuleWebPartSetting") { // Special handling for this one this.divWebParts.Visible = true; using (IDataReader reader = WebPartContent.SelectBySite(siteSettings.SiteId)) { this.ddWebParts.DataSource = reader; this.ddWebParts.DataBind(); } if (s.SettingValue.Length == 36) { ListItem listItem = ddWebParts.Items.FindByValue(s.SettingValue); if (listItem != null) { ddWebParts.ClearSelection(); listItem.Selected = true; } } } else { if (s.SettingControlType == string.Empty) { return; } String settingLabel = s.SettingName; String resourceFile = "Resource"; if (s.ResourceFile.Length > 0) { resourceFile = s.ResourceFile; } try { settingLabel = GetGlobalResourceObject(resourceFile, s.SettingName).ToString(); } catch (NullReferenceException ex) { if (log.IsErrorEnabled) { log.Error("ModuleSettings.aspx.cs error getting resource for s.SettingName " + s.SettingName, ex); } } Panel panel = new Panel(); panel.CssClass = "settingrow"; Literal label = new Literal(); label.Text = "<label class='settinglabel' >" + settingLabel + "</label>"; panel.Controls.Add(label); if ((s.SettingControlType == "TextBox") || (s.SettingControlType == string.Empty)) { Literal textBox = new Literal(); textBox.Text = "<input name=\"" + s.SettingName + this.moduleId.ToInvariantString() + "\" type='text' class=\"forminput\" value=\"" + s.SettingValue.HtmlEscapeQuotes() + "\" size=\"45\" id=\"" + s.SettingName + this.moduleId.ToInvariantString() + "\" />"; panel.Controls.Add(textBox); } if (s.SettingControlType == "CheckBox") { Literal checkBox = new Literal(); String isChecked = String.Empty; if (string.Equals(s.SettingValue, "true", StringComparison.InvariantCultureIgnoreCase)) { isChecked = "checked"; } checkBox.Text = "<input id='" + s.SettingName + this.moduleId.ToInvariantString() + "' type='checkbox' class='forminput' " + isChecked + " name='" + s.SettingName + this.moduleId.ToInvariantString() + "' />"; panel.Controls.Add(checkBox); } if (s.SettingControlType == "ISettingControl") { if (s.ControlSrc.Length > 0) { Control uc = Page.LoadControl(s.ControlSrc); if (uc is ISettingControl) { ISettingControl sc = uc as ISettingControl; if (!IsPostBack) { sc.SetValue(s.SettingValue); } uc.ID = "uc" + moduleId.ToString(CultureInfo.InvariantCulture) + s.SettingName; panel.Controls.Add(uc); } } else { log.Error("could not add setting control for ISettingControl, missing controlsrc for " + s.SettingName); } } if (s.HelpKey.Length > 0) { CHelpLink.AddHelpLink(panel, s.HelpKey); } this.PlaceHolderAdvancedSettings.Controls.Add(panel); } }