protected void RepeaterOptions_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { SettingEntity ThemeSetting = e.Item.DataItem as SettingEntity; String SettingKey = EffectSettingsFormat(lblEffectName.Text, ThemeSetting.Name); ThemeSetting.DefaultValue = Settings[SettingKey] != null?Convert.ToString(Settings[SettingKey]) : ThemeSetting.DefaultValue; //构造输入控件 PlaceHolder ThemePH = e.Item.FindControl("ThemePH") as PlaceHolder; #region "创建控件" ControlHelper ctl = new ControlHelper(this); ctl.IconPath = "Effects"; ThemePH.Controls.Add((Control)ctl.ViewControl(ThemeSetting)); #endregion Literal liTitle = e.Item.FindControl("liTitle") as Literal; liTitle.Text = String.Format("<label class=\"col-sm-3 control-label\" for=\"{1}\">{0}:</label>", !String.IsNullOrEmpty(ThemeSetting.Alias) ? ThemeSetting.Alias : ThemeSetting.Name, ctl.ViewControlID(ThemeSetting)); if (!String.IsNullOrEmpty(ThemeSetting.Description)) { Literal liHelp = e.Item.FindControl("liHelp") as Literal; liHelp.Text = String.Format("<span class=\"help-block\"><i class=\"fa fa-info-circle\"></i> {0}</span>", ThemeSetting.Description); } } }
/// <Description> /// 绑定树分类 /// </Description> private void BindTreeGroups(DNNGo_PowerForms_Field Article) { List <Int32> SelectList = new List <Int32>(); //绑定所有分类到页面 QueryParam qp = new QueryParam(); qp.Orderfld = DNNGo_PowerForms_Group._.Sort; qp.OrderType = 0; int RecordCount = 0; qp.Where.Add(new SearchParam(DNNGo_PowerForms_Group._.ModuleId, ModuleId, SearchType.Equal)); List <DNNGo_PowerForms_Group> lst = DNNGo_PowerForms_Group.FindAll(qp, out RecordCount); StringBuilder GroupListContent = new StringBuilder(); foreach (var Group in lst) { GroupListContent.AppendFormat("{0}:{1}", Group.Name, Group.ID).AppendLine(); } //拼接顶级分类的方法 ControlHelper ctl = new ControlHelper(this); SettingEntity GroupControl = new SettingEntity(); GroupControl.Name = "GroupControl"; GroupControl.Alias = "GroupControl"; GroupControl.ControlType = EnumViewControlType.RadioButtonList.ToString(); GroupControl.DefaultValue = Article.GroupID.ToString(); GroupControl.ListContent = GroupListContent.ToString(); PHGroups.Controls.Add((Control)ctl.ViewControl(GroupControl)); }
/// <summary> /// 创建 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateCheckBox(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<label class=\"checkbox-inline\" for=\"{0}\">", ControlID); ControlHtml.AppendFormat("<input type=\"checkbox\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID); ControlHtml.AppendFormat(" class=\"square-green grey {0}\"", ViewVerification(FieldItem)); if (!String.IsNullOrEmpty(FieldItem.DefaultValue)) { Boolean DefaultValue, b; DefaultValue = b = false; if (FieldItem.DefaultValue == "1" || FieldItem.DefaultValue.Equals(Boolean.TrueString, StringComparison.CurrentCultureIgnoreCase)) { DefaultValue = true; } else if (FieldItem.DefaultValue == "0" || FieldItem.DefaultValue.Equals(Boolean.FalseString, StringComparison.CurrentCultureIgnoreCase)) { DefaultValue = false; } else if (Boolean.TryParse(FieldItem.DefaultValue.ToLower(), out b)) { DefaultValue = b; } if (DefaultValue) { ControlHtml.Append("checked=\"checked\""); } } ControlHtml.Append(" />"); //提示的关键字用作是后面的描述 //if (!String.IsNullOrEmpty(FieldItem.Description)) //{ // ControlHtml.Append(FieldItem.Description); //} ControlHtml.Append("</label>"); //提示的关键字用作是后面的描述 //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) //{ // ControlHtml.AppendFormat("<label for=\"{0}\" title=\"{1}\" style=\"display:inline;\">{1}</label>", ControlID, FieldItem.ToolTip); //} //if (!String.IsNullOrEmpty(FieldItem.Description)) //{ // ControlHtml.AppendFormat("<label for=\"{0}\" title=\"{1}\" style=\"display:inline;\">{1}</label>", ControlID, FieldItem.Description); //} //ControlHtml.Append("</div>"); return(ControlHtml.ToString()); }
/// <summary> /// 创建 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateCheckBoxList(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<span id=\"{1}\" name=\"{0}\" class=\"auto\">", ControlName, ControlID); if (!String.IsNullOrEmpty(FieldItem.ListContent)) { List <String> list = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|"); List <String> DefaultListValue = Common.GetList(FieldItem.DefaultValue); for (Int32 i = 0; i < list.Count; i++) { if (!String.IsNullOrEmpty(list[i])) { String OptionText = list[i]; String OptionValue = list[i]; //判断是否包含有键值对,将键值对分离开 if (list[i].IndexOf(":") >= 0) { List <String> ItemKeyValue = Common.GetList(list[i], ":"); OptionText = ItemKeyValue[0]; OptionValue = ItemKeyValue[1]; //如果有图标就检测,没有就忽略 OptionText = FormatIcon(OptionText); } ControlHtml.AppendFormat("<label for=\"{0}_{1}\" class=\"checkbox-inline\" >", ControlID, i); String CheckedStr = DefaultListValue.Count > 0 && DefaultListValue.Contains(OptionValue) ? "checked=\"checked\"" : ""; ControlHtml.AppendFormat("<input id=\"{1}_{2}\" type=\"checkbox\" name=\"{0}\"", ControlName, ControlID, i); if (FieldItem.Required) { ControlHtml.AppendFormat(" class=\"square-green grey {0}\" ", "validate[minCheckbox[1]]"); } ControlHtml.AppendFormat("value=\"{0}\" {1} />", OptionValue, CheckedStr); ControlHtml.AppendFormat(" {0}</label>", OptionText); if (FieldItem.Direction == EnumControlDirection.Vertical.ToString()) { ControlHtml.Append("<br />"); } } } } ControlHtml.Append(" </span>"); return(ControlHtml.ToString()); }
/// <summary> /// 创建 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateIconPicker(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<select id=\"{0}\" name=\"{1}\" class=\"form-control search-select search-select-auto {2}\" ", ControlID, ControlName, ViewVerification(FieldItem)); ControlHtml.AppendFormat(" style=\"width:{0}px;\" >", FieldItem.Width); List <OptionItem> Optins = new List <OptionItem>(); if (String.IsNullOrEmpty(FieldItem.ListContent))//没有列表项的时候,需要加载默认的字体 { String xml_url = BaseModule.Server.MapPath(String.Format("{0}Resource/xml/SelectIcons.xml", BaseModule.ModulePath)); XmlFormat xf = new XmlFormat(xml_url); Optins = xf.ToList <OptionItem>(); } else if (!String.IsNullOrEmpty(FieldItem.ListContent)) { List <String> list = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|"); for (Int32 i = 0; i < list.Count; i++) { if (!String.IsNullOrEmpty(list[i])) { OptionItem Optin = new OptionItem(); Optin.Text = list[i]; Optin.Value = list[i]; //判断是否包含有键值对,将键值对分离开 if (list[i].IndexOf(":") >= 0) { List <String> ItemKeyValue = Common.GetList(list[i], ":"); Optin.Text = ItemKeyValue[0]; Optin.Value = ItemKeyValue[1]; } Optins.Add(Optin); } } } foreach (var Optin in Optins) { String DisabledStr = String.IsNullOrEmpty(Optin.Value) ? "disabled=\"disabled\"" : ""; String CheckedStr = !String.IsNullOrEmpty(Optin.Value) && FieldItem.DefaultValue.IndexOf(Optin.Value, StringComparison.CurrentCultureIgnoreCase) >= 0 ? "selected=\"selected\"" : ""; ControlHtml.AppendFormat("<option value=\"{0}\" {2} {3}> {1}</option>", Optin.Value, Optin.Text, CheckedStr, DisabledStr).AppendLine(); } ControlHtml.Append("</select>"); return(ControlHtml.ToString()); }
/// <summary> /// /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateLabel(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<span name=\"{0}\" id=\"{1}\"", ControlName, ControlID); //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip); if (!String.IsNullOrEmpty(FieldItem.DefaultValue)) { FieldItem.DefaultValue = Common.ReplaceNoCase(FieldItem.DefaultValue, "[ModuleId]", BaseModule.ModuleId.ToString()); } ControlHtml.AppendFormat(">{0}</span>", FieldItem.DefaultValue); return(ControlHtml.ToString()); }
/// <summary> /// 创建 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateFileUpload(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<input type=\"file\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID); //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip); ControlHtml.AppendFormat(" class=\"file-input validate[{0}ajax[ajaxUpload]]\"", FieldItem.Required ? "required," : ""); ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width < 250 ? 250 : FieldItem.Width); ControlHtml.Append(" />"); return(ControlHtml.ToString()); }
/// <summary> /// 创建 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateDatePicker(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.Append(ViewCreateTextBox(FieldItem, ControlName, ControlID)); ControlHtml.Append("<script type=\"text/javascript\">"); ControlHtml.Append("jQuery(document).ready(function(){").AppendLine(); ControlHtml.Append(" jQuery(function() {").AppendLine(); ControlHtml.AppendFormat(" jQuery(\"#{0}\").datepicker({{showButtonPanel: true,changeMonth: true,changeYear: true}});", ControlID).AppendLine(); ControlHtml.Append(" });").AppendLine(); ControlHtml.Append("});").AppendLine(); ControlHtml.Append("</script>"); return(ControlHtml.ToString()); }
/// <summary> /// 创建URLs /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <param name="ControlID"></param> /// <returns></returns> public Control ViewCreateUrls(SettingEntity FieldItem, String ControlName, String ControlID) { string ContentSrc = BaseModule.ResolveClientUrl(string.Format("{0}Resource_RichUrls.ascx", BaseModule.ModulePath)); if (System.IO.File.Exists(BaseModule.MapPath(ContentSrc))) { Resource_RichUrls ManageContent = new Resource_RichUrls(); ManageContent = (Resource_RichUrls)BaseModule.LoadControl(ContentSrc); ManageContent.ModuleConfiguration = BaseModule.ModuleConfiguration; ManageContent.ID = ControlID; ManageContent.LocalResourceFile = Localization.GetResourceFile(ManageContent.Control, string.Format("{0}.resx", "Resource_RichUrls.ascx")); ManageContent.FieldItem = FieldItem; return(ManageContent); } return(new Literal()); }
/// <summary> /// 创建 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateColorPicker(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML if (String.IsNullOrEmpty(FieldItem.DefaultValue)) { FieldItem.DefaultValue = "#ffffff"; } ControlHtml.AppendFormat("<div class=\"input-group\" style=\"width:{0}px;\">", FieldItem.Width); ControlHtml.AppendFormat("<label class=\"input-group-addon color-picker-box tooltips\" for=\"{0}\" style=\"background-color: {1};\"> <i class=\"clip-eyedropper-2 \" ></i> </label>", ControlID, FieldItem.DefaultValue); ControlHtml.AppendFormat("<input type=\"text\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID); //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip); ControlHtml.AppendFormat(" class=\"form-control color-picker-auto input_text {0}\"", ViewVerification(FieldItem)); ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width - 40); if (!String.IsNullOrEmpty(FieldItem.DefaultValue)) { ControlHtml.AppendFormat(" value=\"{0}\"", FieldItem.DefaultValue); } if (!String.IsNullOrEmpty(FieldItem.ListContent)) { ControlHtml.AppendFormat(" data-color-format=\"{0}\"", FieldItem.ListContent); } ControlHtml.Append(" />"); ControlHtml.Append("</div>"); //ControlHtml.Append("<div class=\"input-group colorpicker-component\" data-color=\"rgb(81, 145, 185)\" data-color-format=\"rgb\">"); //ControlHtml.Append(ViewCreateTextBox(FieldItem, ControlName, ControlID)); //ControlHtml.Append("<span class=\"input-group-addon\"><i style=\"background-color: rgb(81, 145, 185)\"></i></span>"); //ControlHtml.Append("</div>"); return(ControlHtml.ToString()); }
/// <summary> /// 创建TextBox /// </summary> /// <param name="FieldItem"></param> /// <returns></returns> public String ViewCreateTextBox(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML //看行数决定控件的是什么控件 if (FieldItem.Rows > 1) { ControlHtml.AppendFormat("<textarea name=\"{0}\" id=\"{1}\"", ControlName, ControlID); //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip); ControlHtml.AppendFormat(" class=\"form-control input_text {0}\"", ViewVerification(FieldItem)); ControlHtml.AppendFormat(" style=\"width:{0}px;height:{1}px;\" rows=\"{2}\"", FieldItem.Width, FieldItem.Rows * 20, FieldItem.Rows); ControlHtml.Append(" >"); //默认值 if (!String.IsNullOrEmpty(FieldItem.DefaultValue)) { ControlHtml.Append(FieldItem.DefaultValue); } ControlHtml.Append("</textarea>"); } else { ControlHtml.AppendFormat("<input type=\"text\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID); //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip); ControlHtml.AppendFormat(" class=\"form-control input_text {0}\"", ViewVerification(FieldItem)); ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width); if (!String.IsNullOrEmpty(FieldItem.DefaultValue)) { ControlHtml.AppendFormat(" value=\"{0}\"", FieldItem.DefaultValue); } ControlHtml.Append(" />"); } return(ControlHtml.ToString()); }
/// <summary> /// 创建下拉列表by 分组 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <param name="ControlID"></param> /// <returns></returns> public String ViewCreateDropDownListByGroup(SettingEntity FieldItem, String ControlName, String ControlID) { //构造国家数据 StringBuilder sb = new StringBuilder(FieldItem.ListContent); List <DNNGo_PowerForms_Group> Groups = DNNGo_PowerForms_Group.FindAllByModuleID(ModuleId); if (Groups != null && Groups.Count > 0) { foreach (DNNGo_PowerForms_Group info in Groups) { if (info != null && !String.IsNullOrEmpty(info.Name)) { sb.AppendFormat("|{0}", info.Name); } } FieldItem.ListContent = sb.ToString(); } return(ViewCreateDropDownList(FieldItem, ControlName, ControlID)); }
/// <summary> /// 获取Form传值 /// </summary> /// <param name="fieldItem"></param> /// <returns></returns> public static String GetWebFormValue(SettingEntity fieldItem, basePortalModule bpm) { String WebFormValue = String.Empty; //创建控件的Name和ID ControlHelper ControlItem = new ControlHelper(bpm.ModuleId); String ControlName = ControlItem.ViewControlName(fieldItem); String ControlID = ControlItem.ViewControlID(fieldItem); if (fieldItem.ControlType == EnumControlType.CheckBox.ToString()) { WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, ""); WebFormValue = !String.IsNullOrEmpty(WebFormValue) && WebFormValue == "on" ? "true" : "false"; } else if (fieldItem.ControlType == EnumControlType.FileUpload.ToString()) { HttpPostedFile hpFile = HttpContext.Current.Request.Files[ControlName]; //To verify that if the suffix name of the uploaded files meets the DNN HOST requirements Boolean retValue = FileSystemUtils.CheckValidFileName(hpFile.FileName); if (retValue) { if (hpFile != null && hpFile.ContentLength > 0) { WebFormValue = String.Format("Url://{0}", FileSystemUtils.UploadFile(hpFile, bpm)); //存放到目录中,并返回 } } } else if (fieldItem.ControlType == EnumControlType.Urls.ToString()) { String ClientName = GetRichUrlsName(fieldItem); if (bpm.HttpContext.Items.Contains(ClientName)) { WebFormValue = Convert.ToString(bpm.HttpContext.Items[ClientName]); } } else { WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, ""); } return(WebFormValue); }
/// <summary> /// /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateRadioButtonList(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<span id=\"{0}\" class=\"{1} auto\" >", ControlID, ViewVerification(FieldItem)); if (!String.IsNullOrEmpty(FieldItem.ListContent)) { List <String> list = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|"); for (Int32 i = 0; i < list.Count; i++) { if (!String.IsNullOrEmpty(list[i])) { String OptionText = list[i]; String OptionValue = list[i]; String OptionImage = String.Empty; //判断是否包含有键值对,将键值对分离开 if (list[i].IndexOf(":") >= 0) { List <String> ItemKeyValue = Common.GetList(list[i], ":"); OptionText = ItemKeyValue[0]; OptionValue = ItemKeyValue[1]; //如果有图标就检测,没有就忽略 OptionText = FormatIcon(OptionText); } String CheckedStr = FieldItem.DefaultValue.IndexOf(OptionValue, StringComparison.CurrentCultureIgnoreCase) >= 0 ? "checked=\"checked\"" : ""; ControlHtml.AppendFormat("<label class=\"radio-inline\" for=\"{1}_{2}\" ><input id=\"{1}_{2}\" type=\"radio\" name=\"{0}\" value=\"{3}\" {4} /> {5}</label>", ControlName, ControlID, i, OptionValue, CheckedStr, OptionText); if (FieldItem.Direction == EnumControlDirection.Vertical.ToString()) { ControlHtml.Append("<br />"); } } } } ControlHtml.Append(" </span>"); return(ControlHtml.ToString()); }
/// <summary> /// /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateListBox(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<select name=\"{0}\" id=\"{1}\"", ControlName, ControlID); ControlHtml.AppendFormat(" class=\"form-control input_text {0}\"", ViewVerification(FieldItem)); ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width); ControlHtml.AppendFormat(" size=\"{0}\" multiple=\"multiple\">", FieldItem.Rows); if (!String.IsNullOrEmpty(FieldItem.ListContent)) { List <String> list = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|"); List <String> DefaultListValue = Common.GetList(FieldItem.DefaultValue); for (Int32 i = 0; i < list.Count; i++) { if (!String.IsNullOrEmpty(list[i])) { String OptionText = list[i]; String OptionValue = list[i]; //判断是否包含有键值对,将键值对分离开 if (list[i].IndexOf(":") >= 0) { List <String> ItemKeyValue = Common.GetList(list[i], ":"); OptionText = ItemKeyValue[0]; OptionValue = ItemKeyValue[1]; } String CheckedStr = DefaultListValue.Count > 0 && DefaultListValue.Contains(OptionValue) ? "selected=\"selected\"" : ""; String DisabledStr = String.IsNullOrEmpty(OptionValue) ? "disabled=\"disabled\"" : ""; ControlHtml.AppendFormat("<option {0} {1} value=\"{2}\">{3}</option>", CheckedStr, DisabledStr, OptionValue, OptionText); } } } ControlHtml.Append(" </select>"); return(ControlHtml.ToString()); }
/// <summary> /// /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <returns></returns> public String ViewCreateRichTextBox(SettingEntity FieldItem, String ControlName, String ControlID) { StringBuilder ControlHtml = new StringBuilder();//控件的HTML ControlHtml.AppendFormat("<textarea name=\"{0}\" id=\"{1}\"", ControlName, ControlID); //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip); ControlHtml.AppendFormat(" class=\"form-control tinymce input_text {0}\"", ViewVerification(FieldItem)); ControlHtml.AppendFormat(" style=\"width:{0}px;height:{1}px;\" rows=\"{2}\"", FieldItem.Width, FieldItem.Rows * 20, FieldItem.Rows); ControlHtml.Append(" >"); //默认值 if (!String.IsNullOrEmpty(FieldItem.DefaultValue)) { ControlHtml.Append(FieldItem.DefaultValue); } ControlHtml.Append("</textarea>"); //ControlHtml.Append(ViewCreateTextBox(FieldItem, ControlName, ControlID)); //ControlHtml.Append("<script>"); //ControlHtml.Append("var editor;").AppendLine(); //ControlHtml.Append("KindEditor.ready(function (K) {").AppendLine(); //ControlHtml.AppendFormat(" editor = K.create('#{0}', {{", ControlID).AppendLine(); //ControlHtml.Append(" afterBlur: function(){this.sync();},allowPreviewEmoticons: false,allowImageUpload: false,").AppendLine(); //ControlHtml.Append(" items: [ 'source', '|','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline','removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist', '|', 'emoticons', 'image', 'link']").AppendLine(); //ControlHtml.Append(" });").AppendLine(); //ControlHtml.Append(" });").AppendLine(); //ControlHtml.Append("</script>"); return(ControlHtml.ToString()); }
protected void RepeaterOptions_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { SettingEntity ThemeSetting = e.Item.DataItem as SettingEntity; Boolean IsRightLayout = !String.IsNullOrEmpty(ThemeSetting.Layout) && ThemeSetting.Layout.IndexOf("Right", StringComparison.CurrentCultureIgnoreCase) >= 0; KeyValueEntity KeyValue = ItemSettings.Find(r1 => r1.Key == ThemeSetting.Name); if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key)) { ThemeSetting.DefaultValue = KeyValue.Value.ToString(); } //构造输入控件 PlaceHolder ThemePH = e.Item.FindControl("ThemePH") as PlaceHolder; #region "创建控件" ControlHelper ctl = new ControlHelper(this); ThemePH.Controls.Add((Control)ctl.ViewControl(ThemeSetting)); #endregion Literal liTitle = e.Item.FindControl("liTitle") as Literal; liTitle.Text = String.Format("<label class=\"col-sm-{2} control-label\" for=\"{1}\">{0}:</label>", !String.IsNullOrEmpty(ThemeSetting.Alias) ? ThemeSetting.Alias : ThemeSetting.Name, ctl.ViewControlID(ThemeSetting), IsRightLayout ? 5 : 3); if (!String.IsNullOrEmpty(ThemeSetting.Description)) { Literal liHelp = e.Item.FindControl("liHelp") as Literal; liHelp.Text = String.Format("<span class=\"help-block\"><i class=\"fa fa-info-circle\"></i> {0}</span>", ThemeSetting.Description); } } }
/// <summary> /// 验证字符 /// </summary> /// <param name="FieldItem"></param> /// <returns></returns> public String ViewVerification(SettingEntity FieldItem) { //无验证时退出 //if (FieldItem.Verification == EnumVerification.optional.ToString() && !FieldItem.Required) return ""; String custom = String.Empty; if (!String.IsNullOrEmpty(FieldItem.Verification) && FieldItem.Verification != EnumVerification.optional.ToString()) { if (!(("DropDownList,ListBox,RadioButtonList,FileUpload,CheckBox,CheckBoxList,Label").IndexOf(FieldItem.ControlType) >= 0)) { custom = String.Format("custom[{0}]", FieldItem.Verification); } } if (!String.IsNullOrEmpty(custom)) { if (!FieldItem.Required) { return(String.Format("validate[{0}]", String.IsNullOrEmpty(custom) ? "optional" : custom)); } else { return(String.Format("validate[required,{0}]", custom)); } } else { if (FieldItem.Required) { return("validate[required]"); } else { return(""); } } }
/// <summary> /// 显示输入控件内容 /// </summary> /// <param name="FieldItem"></param> /// <returns></returns> public Control ViewControl(SettingEntity FieldItem) { String ControlName = ViewControlName(FieldItem); String ControlID = ViewControlID(FieldItem); Control CreateControl = new Control(); String ControlHtml = String.Empty;//控件的HTML if (FieldItem.ControlType == EnumControlType.CheckBox.ToString()) { ControlHtml = ViewCreateCheckBox(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.CheckBoxList.ToString()) { ControlHtml = ViewCreateCheckBoxList(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.DatePicker.ToString()) { ControlHtml = ViewCreateDatePicker(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.ColorPicker.ToString()) { ControlHtml = ViewCreateColorPicker(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.IconPicker.ToString()) { ControlHtml = ViewCreateIconPicker(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.DropDownList.ToString()) { ControlHtml = ViewCreateDropDownList(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.DropDownList_Group.ToString()) { ControlHtml = ViewCreateDropDownListByGroup(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.FileUpload.ToString()) { ControlHtml = ViewCreateFileUpload(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.Urls.ToString()) { CreateControl = ViewCreateUrls(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.Label.ToString()) { ControlHtml = ViewCreateLabel(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.ListBox.ToString()) { ControlHtml = ViewCreateListBox(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.RadioButtonList.ToString()) { ControlHtml = ViewCreateRadioButtonList(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.RichTextBox.ToString()) { ControlHtml = ViewCreateRichTextBox(FieldItem, ControlName, ControlID); } else if (FieldItem.ControlType == EnumControlType.TextBox.ToString() || FieldItem.ControlType.IndexOf("text") >= 0) { ControlHtml = ViewCreateTextBox(FieldItem, ControlName, ControlID); } if (!String.IsNullOrEmpty(ControlHtml)) { Literal liHtml = new Literal(); liHtml.Text = ControlHtml; CreateControl = liHtml; } return(CreateControl); }
/// <summary> /// 设置方案项 /// </summary> private Int32 SetDataItem(Int32 ArticleStatus, out DNNGo_PowerForms_Field fieldItem) { fieldItem = FieldItem; //权限 fieldItem.Per_AllUsers = cbPermissionsAllUsers.Checked ? 0 : 1; String textStr, idStr = String.Empty; WebHelper.GetSelected(cblPermissionsRoles, out textStr, out idStr); fieldItem.Per_Roles = idStr; if (ddlControlType.Enabled) { fieldItem.FieldType = WebHelper.GetIntParam(Request, ddlControlType.UniqueID, (Int32)EnumViewControlType.TextBox); } fieldItem.ToolTip = txtToolTip.Text; fieldItem.Alias = txtAlias.Text; fieldItem.Description = txtDescription.Text; fieldItem.Required = cbRequired.Checked ? 1 : 0; fieldItem.Options = SetItemSettings(); if (divGroup.Visible) { SettingEntity GroupControl = new SettingEntity(); GroupControl.Name = "GroupControl"; Int32 GroupID = 0; if (int.TryParse(ControlHelper.GetWebFormValue(GroupControl, this), out GroupID)) { } fieldItem.GroupID = GroupID; } fieldItem.FiledList = txtFTListCollection.Text; if (fieldItem.FieldType == (Int32)EnumViewControlType.Html || fieldItem.FieldType == (Int32)EnumViewControlType.RichTextBox) { fieldItem.DefaultValue = txtTinymceDefaultValue.Text; } else { fieldItem.DefaultValue = txtFTDefaultValue.Text; } fieldItem.Rows = WebHelper.GetIntParam(Request, txtFTRows.UniqueID, 1); fieldItem.Verification = WebHelper.GetIntParam(Request, ddlVerification.UniqueID, 0); fieldItem.Direction = WebHelper.GetIntParam(Request, rblFTDirection.UniqueID, 0); fieldItem.ListColumn = WebHelper.GetIntParam(Request, txtFTListColumn.UniqueID, 1); fieldItem.Width = WebHelper.GetIntParam(Request, txtFTWidth.UniqueID, 100); fieldItem.WidthSuffix = WebHelper.GetIntParam(Request, ddlFTWidth.UniqueID, 0); fieldItem.EqualsControl = WebHelper.GetIntParam(Request, ddlFTEqualsControl.UniqueID, 0); fieldItem.AssociatedControl = WebHelper.GetIntParam(Request, ddlFTAssociatedControl.UniqueID, 0); fieldItem.InputLength = WebHelper.GetIntParam(Request, txtFTInputLength.UniqueID, 2000); fieldItem.LastTime = xUserTime.UtcTime(); fieldItem.LastUser = UserId; fieldItem.LastIP = WebHelper.UserHost; //发布状态和时间 DateTime oTime = xUserTime.LocalTime(); string[] expectedFormats = { "G", "g", "f", "F" }; string StartDate = WebHelper.GetStringParam(Request, txtStartDate.UniqueID, oTime.ToString("MM/dd/yyyy")); string StartTime = WebHelper.GetStringParam(Request, txtStartTime.UniqueID, oTime.ToString("hh:mm tt")); if (DateTime.TryParseExact(String.Format("{0} {1}", StartDate, StartTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out oTime)) { fieldItem.StartTime = oTime; } //发布状态和时间 DateTime EndTime = xUserTime.LocalTime().AddYears(10); string DisableDate = WebHelper.GetStringParam(Request, txtDisableDate.UniqueID, EndTime.ToString("MM/dd/yyyy")); string DisableTime = WebHelper.GetStringParam(Request, txtDisableTime.UniqueID, EndTime.ToString("hh:mm tt")); if (DateTime.TryParseExact(String.Format("{0} {1}", DisableDate, DisableTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out EndTime)) { fieldItem.EndTime = EndTime; } if (ArticleStatus == -1)//如果没有指定状态就取控件的 { fieldItem.Status = cbStatus.Checked ? (Int32)EnumStatus.Activation : (Int32)EnumStatus.Hide; } else { fieldItem.Status = ArticleStatus; } Int32 SaveResult = 0; if (fieldItem.ID > 0) { SaveResult = fieldItem.Update(); } else { fieldItem.Name = txtName.Text; QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, fieldItem.Name, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) == 0) { fieldItem.ModuleId = ModuleId; fieldItem.PortalId = PortalId; QueryParam Sqp = new QueryParam(); Sqp.ReturnFields = Sqp.Orderfld = DNNGo_PowerForms_Field._.Sort; Sqp.OrderType = 1; Sqp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal)); fieldItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Field.FindScalar(Sqp)) + 2; //构造默认的验证方式 if (fieldItem.FieldType == (Int32)EnumViewControlType.DatePicker) { fieldItem.Verification = (Int32)EnumVerification.date; } else if (fieldItem.FieldType == (Int32)EnumViewControlType.FileUpload) { } else if (fieldItem.FieldType == (Int32)EnumViewControlType.TextBox_Email) { fieldItem.Verification = (Int32)EnumVerification.email; } SaveResult = fieldItem.Insert(); } else { SaveResult = -1; } } return(SaveResult); }
public String ViewControlID(SettingEntity FieldItem) { return(String.Format("Ctl_{0}", FieldItem.Name)); //return String.Format("Ctl_{0}_{1}", FieldItem.Name, ModuleId); }
/// <summary> /// 显示标题控件 /// </summary> /// <param name="FieldItem"></param> /// <returns></returns> public String ViewLable(SettingEntity FieldItem) { return(ViewLable(FieldItem, ""));; }
/// <summary> /// 显示标题控件 /// </summary> /// <param name="FieldItem">显示字段</param> /// <param name="Suffix">后缀名</param> /// <returns></returns> public String ViewLable(SettingEntity FieldItem, String Suffix) { String ControlName = ViewControlID(FieldItem); return(String.Format("<label for=\"{0}\">{1}{2}</label>", ControlName, FieldItem.Alias, Suffix)); }
/// <summary> /// 获取URLs控件的名称 /// </summary> /// <param name="fieldItem"></param> /// <returns></returns> public static String GetRichUrlsName(SettingEntity fieldItem) { return(String.Format("RichUrls{0}", fieldItem.Name).Replace("_", "").Replace("-", "")); }