protected override void AddAttributesToRender(HtmlTextWriter writer) { AddAttributesToRender(writer); if (RenderUplevel) { if (Helpers.EnableLegacyRendering()) { writer.AddAttribute("evaluationfunction", "ClientValidateDate", false); writer.AddAttribute("required", Required.ToString().ToLower(), false); writer.AddAttribute("dateSeparator", CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator, false); writer.AddAttribute("shortDatePattern", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern, false); writer.AddAttribute("minDate", MinDate.ToString(), false); writer.AddAttribute("maxDate", MaxDate.ToString(), false); writer.AddAttribute("invalidErrorMessage", InvalidErrorMessage, true); writer.AddAttribute("requiredErrorMessage", RequiredErrorMessage, true); } else { Page.ClientScript.RegisterExpandoAttribute(ClientID, "evaluationfunction", "ClientValidateDate", false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "required", Required.ToString().ToLower(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "dateSeparator", CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator, false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "shortDatePattern", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern, false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "minDate", MinDate.ToString(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "maxDate", MaxDate.ToString(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "invalidErrorMessage", InvalidErrorMessage, true); Page.ClientScript.RegisterExpandoAttribute(ClientID, "requiredErrorMessage", RequiredErrorMessage, true); } } }
/// <summary> /// This is where you implement the simple aspects of rendering your control. The rest /// will be handled by calling RenderControlHelper's RenderControl() method. /// </summary> /// <param name="writer">The writer.</param> public void RenderBaseControl(HtmlTextWriter writer) { string errorMessage; if (!string.IsNullOrWhiteSpace(RequiredErrorMessage)) { errorMessage = RequiredErrorMessage; } else if (!string.IsNullOrWhiteSpace(Label)) { errorMessage = Label + " Is Required"; } else { errorMessage = "Please complete the captcha"; } writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID); writer.AddAttribute("data-required", Required.ToString().ToLower()); writer.AddAttribute("data-required-error-message", errorMessage); writer.AddAttribute(HtmlTextWriterAttribute.Class, "js-captcha " + CssClass); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderEndTag(); CustomValidator.RenderControl(writer); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { AddAttributesToRender(writer); if (RenderUplevel) { if (Helpers.EnableLegacyRendering()) { writer.AddAttribute("evaluationfunction", "ClientValidateNumber", false); writer.AddAttribute("required", Required.ToString().ToLower(), false); writer.AddAttribute("minvalue", MinValue, false); writer.AddAttribute("maxvalue", MaxValue, false); writer.AddAttribute("numbertype", NumberType.ToString(), false); writer.AddAttribute("invalidErrorMessage", InvalidErrorMessage, true); writer.AddAttribute("requiredErrorMessage", RequiredErrorMessage, true); writer.AddAttribute("decimalSeparator", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); writer.AddAttribute("groupSeparator", CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator); } else { Page.ClientScript.RegisterExpandoAttribute(ClientID, "evaluationfunction", "ClientValidateNumber", false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "required", Required.ToString().ToLower(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "minvalue", MinValue, false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "maxvalue", MaxValue, false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "numbertype", NumberType.ToString(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "invalidErrorMessage", InvalidErrorMessage, true); Page.ClientScript.RegisterExpandoAttribute(ClientID, "requiredErrorMessage", RequiredErrorMessage, true); Page.ClientScript.RegisterExpandoAttribute(ClientID, "decimalSeparator", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "groupSeparator", CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator, false); } } }
/// <summary> /// Renders the attribute to a JSON formatted string. /// </summary> /// <returns></returns> public override string ToString() { return("{" + string.Format("label:\"{0}\",placeholder:\"{1}\",autofocus:{2},required:{3},validate:{4},pattern:\"{5}\",errorClass:\"{6}\",errorMessage:\"{7}\"", Label ?? string.Empty, Placeholder ?? string.Empty, Autofocus.ToString().ToLower(), Required.ToString().ToLower(), Validate.ToString().ToLower(), Pattern ?? string.Empty, ErrorClass ?? string.Empty, ErrorMessage ?? string.Empty) + "}"); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { AddAttributesToRender(writer); // Add the client side-code (if needed) if (RenderUplevel) { // Indicate the required and validationExpression values and the client-side function to be used for evaluation // Use AddAttribute if Helpers.EnableLegacyRendering is true; otherwise, use expando attributes if (Helpers.EnableLegacyRendering()) { writer.AddAttribute("evaluationfunction", "ClientValidateExpression", false); writer.AddAttribute("required", Required.ToString().ToLower(), false); writer.AddAttribute("validationExpression", ValidationExpression, true); writer.AddAttribute("requiredErrorMessage", RequiredErrorMessage, true); writer.AddAttribute("invalidErrorMessage", InvalidErrorMessage, true); } else { Page.ClientScript.RegisterExpandoAttribute(ClientID, "evaluationfunction", "ClientValidateExpression", false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "required", Required.ToString().ToLower(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "validationExpression", ValidationExpression, true); Page.ClientScript.RegisterExpandoAttribute(ClientID, "requiredErrorMessage", RequiredErrorMessage, true); Page.ClientScript.RegisterExpandoAttribute(ClientID, "invalidErrorMessage", InvalidErrorMessage, true); } } }
public XmlNode GenerateXML() { // Create XML Node and Attributes XmlDocument d = new XmlDocument(); XmlNode output = d.CreateNode("element", "InputChoice", null); XmlAttribute alternateVariable = d.CreateAttribute("AlternateVariable"); XmlAttribute autoComplete = d.CreateAttribute("AutoComplete"); XmlAttribute _default = d.CreateAttribute("Default"); XmlAttribute dropDownSize = d.CreateAttribute("DropDownSize"); XmlAttribute question = d.CreateAttribute("Question"); // required XmlAttribute required = d.CreateAttribute("Required"); XmlAttribute sort = d.CreateAttribute("Sort"); XmlAttribute variable = d.CreateAttribute("Variable"); // required XmlAttribute condition = d.CreateAttribute("Condition"); // Set Attribute values alternateVariable.Value = AlternateVariable; autoComplete.Value = AutoComplete.ToString(); _default.Value = Default; dropDownSize.Value = DropDownSize.ToString(); question.Value = Question; required.Value = Required.ToString(); sort.Value = Sort.ToString(); variable.Value = Variable; condition.Value = Condition; // Append Attributes if (!string.IsNullOrEmpty(AlternateVariable)) { output.Attributes.Append(alternateVariable); } output.Attributes.Append(autoComplete); if (!string.IsNullOrEmpty(Default)) { output.Attributes.Append(_default); } output.Attributes.Append(dropDownSize); output.Attributes.Append(question); if (null != Required) { output.Attributes.Append(required); } output.Attributes.Append(sort); output.Attributes.Append(variable); if (!string.IsNullOrEmpty(Condition)) { output.Attributes.Append(condition); } // Append Children foreach (IChildElement choice in SubChildren) { XmlNode importNode = d.ImportNode(choice.GenerateXML(), true); output.AppendChild(importNode); } return(output); }
protected override void CreateChildControls() { base.CreateChildControls(); CountryName.ControlStyle.CopyFrom(ControlStyle); CountryName.ID = ID + "_name"; CountryName.Attributes.Add("data-name", Name); CountryName.Attributes.Add("data-list", "Country"); CountryName.Attributes.Add("data-category", Category); CountryName.Attributes.Add("data-editor", "DnnCountryAutocompleteControl"); CountryName.Attributes.Add("data-required", Required.ToString().ToLowerInvariant()); Controls.Add(CountryName); CountryId.ID = ID + "_id"; Controls.Add(CountryId); }
/// <summary> /// 保存XML信息 /// </summary> /// <param name="doc"></param> /// <returns></returns> public XmlElement ToXml(XmlDocument doc) { XmlElement xe = doc.CreateElement("Parameter"); xe.SetAttribute("name", Name); xe.SetAttribute("title", Title); xe.SetAttribute("type", Type); xe.SetAttribute("maximum", Maximum); xe.SetAttribute("minimum", Minium); xe.SetAttribute("length", Length.ToString()); xe.SetAttribute("description", Description); xe.SetAttribute("required", Required.ToString()); xe.SetAttribute("defaultValue", DefaultValue); xe.SetAttribute("supportCopy", SupportCopy.ToString()); xe.SetAttribute("data", Data); return(xe); }
public XmlNode GenerateXML() { // Create XML Node and Attributes XmlDocument d = new XmlDocument(); XmlNode output = d.CreateNode("element", "SoftwareGroup", null); XmlAttribute _default = d.CreateAttribute("Default"); XmlAttribute id = d.CreateAttribute("Id"); XmlAttribute label = d.CreateAttribute("Label"); XmlAttribute required = d.CreateAttribute("Required"); XmlAttribute condition = d.CreateAttribute("Condition"); // Assign Attribute Values _default.Value = Default.ToString(); id.Value = Id; label.Value = Label; required.Value = Required.ToString(); condition.Value = Condition; // Append Attributes if (null != Default) { output.Attributes.Append(_default); } output.Attributes.Append(id); output.Attributes.Append(label); if (null != Required) { output.Attributes.Append(required); } if (!string.IsNullOrEmpty(Condition)) { output.Attributes.Append(condition); } // Append Children foreach (ISoftwareRef softwareRef in SubChildren) { XmlNode importNode = d.ImportNode(softwareRef.GenerateXML(), true); output.AppendChild(importNode); } return(output); }
public override string ToString() { return("<Data>" + "<Param key=\"ParentWebID\">" + ParentWebID.ToString() + "</Param>" + "<Param key=\"LookupWebID\">" + LookupWebID.ToString() + "</Param>" + "<Param key=\"LookupListID\">" + LookupListID.ToString() + "</Param>" + "<Param key=\"LookupFieldInternalName\">" + LookupFieldInternalName + "</Param>" + "<Param key=\"LookupFieldID\">" + LookupFieldSourceFieldID.ToString() + "</Param>" + "<Param key=\"IsMultiSelect\">" + IsMultiSelect + "</Param>" + "<Param key=\"ListID\">" + ListID.ToString() + "</Param>" + "<Param key=\"ItemID\">" + ItemID.ToString() + "</Param>" + "<Param key=\"SourceControlID\">" + (!string.IsNullOrEmpty(SourceControlID) ? SourceControlID : string.Empty) + "</Param>" + "<Param key=\"SelectCandidateID\">" + (!string.IsNullOrEmpty(SelectCandidateID) ? SelectCandidateID : string.Empty) + "</Param>" + "<Param key=\"AddButtonID\">" + (!string.IsNullOrEmpty(AddButtonID) ? AddButtonID : string.Empty) + "</Param>" + "<Param key=\"RemoveButtonID\">" + (!string.IsNullOrEmpty(RemoveButtonID) ? RemoveButtonID : string.Empty) + "</Param>" + "<Param key=\"SelectResultID\">" + (!string.IsNullOrEmpty(SelectResultID) ? SelectResultID : string.Empty) + "</Param>" + "<Param key=\"Required\">" + Required.ToString() + "</Param>" + "</Data>"); }
protected override void Render(HtmlTextWriter writer) { CssClass = CssClass + " validator"; if (MinLength > 0) { Attributes["minlength"] = MinLength.ToString(); } if (MaxLength > 0 && MaxLength > MinLength) { Attributes["maxlength"] = MaxLength.ToString(); } if (!string.IsNullOrEmpty(Group)) { Attributes["group"] = Group; } if (!string.IsNullOrEmpty(GroupMessage)) { Attributes["groupmessage"] = GroupMessage; } if (Required) { Attributes["required"] = Required.ToString(); } if (CustomFunction == null) { CustomFunction = Function.ToString(); } Attributes["function"] = CustomFunction; if (!string.IsNullOrEmpty(ControlToValidate)) { Attributes["validates"] = ControlToValidate; } base.Render(writer); }
protected override void RenderEditMode(HtmlTextWriter writer) { if (ListEntries != null && ListEntries.Any()) { foreach (ListEntryInfo item in ListEntries) { Regions.Items.Add(new ListItem() { Text = item.Text, Value = item.EntryID.ToString() }); } } ControlStyle.AddAttributesToRender(writer); writer.AddAttribute("data-name", Name); writer.AddAttribute("data-list", "Region"); writer.AddAttribute("data-category", Category); writer.AddAttribute("data-required", Required.ToString().ToLowerInvariant()); writer.RenderBeginTag(HtmlTextWriterTag.Div); RenderChildren(writer); writer.RenderEndTag(); }
public XmlNode GenerateXML() { // Create XML Node and Attributes XmlDocument d = new XmlDocument(); XmlNode output = d.CreateNode("element", "SoftwareRef", null); XmlAttribute id = d.CreateAttribute("Id"); XmlAttribute hidden = d.CreateAttribute("Hidden"); XmlAttribute _default = d.CreateAttribute("Default"); XmlAttribute required = d.CreateAttribute("Required"); XmlAttribute condition = d.CreateAttribute("Condition"); // Set Attribute Values id.Value = Id; hidden.Value = Hidden.ToString(); _default.Value = Default.ToString(); required.Value = Required.ToString(); condition.Value = Condition; // Append Attributes output.Attributes.Append(id); if (null != Hidden) { output.Attributes.Append(hidden); } if (null != Default) { output.Attributes.Append(_default); } if (null != Required) { output.Attributes.Append(required); } if (!string.IsNullOrEmpty(Condition)) { output.Attributes.Append(condition); } return(output); }
public override string SelfGenerateControlUI <TModel>(ControlFormResult <TModel> controlForm, WorkContext workContext, HtmlHelper htmlHelper) { var id = htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldId(Name); if (!EnableFineUploader) { return(string.Format(Required ? "<input type=\"file\" name=\"{0}\" class=\"{1}\" id=\"{2}\" data-val=\"true\" data-val-required=\"{3}\" /><span data-valmsg-for=\"{0}\" data-valmsg-replace=\"true\"></span>" : "<input type=\"file\" name=\"{0}\" class=\"{1}\" id=\"{2}\" />", Name, CssClass, id, Constants.Messages.Validation.Required)); } var options = controlForm.GetFileUploadOptions(Name); var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext); var uploadUrl = options.UploadUrl ?? urlHelper.Action("UploadFiles", "UploadFiles", new { area = Constants.Areas.Media }); var uploadFolder = options.UploadFolder; if (string.IsNullOrEmpty(uploadFolder)) { uploadFolder = UploadFolder; } string browseButton = null; if (AllowBrowseOnServer) { browseButton = string.Format("<button class=\"btn btn-default qq-browse-button\" onclick=\"$.fancybox.open({{ href: '{0}', type: 'iframe', modal: true, padding: 0, width: 500, height: 200, autoSize: false, minHeight: 250, afterClose: function(){{ if(window.fancyboxResult){{ $('#{1}, #{1}_Validator').val(window.fancyboxResult); $('#{1}_UploadList').html(window.fancyboxResult); }} }} }}); return false;\"><i class=\"cx-icon cx-icon-folder-open\"></i></button>", urlHelper.Action("Browse", "Media", new { area = Constants.Areas.Media }), id); } var clientOptions = new JObject { new JProperty("multiple", false), new JProperty("paramsInBody", true), new JProperty("validation", new JObject( new JProperty("allowedExtensions", GetAllowedExtensions(options.AllowedExtensions ?? AllowedExtensions)), new JProperty("sizeLimit", options.SizeLimit))), new JProperty("request", new JObject(new JProperty("endpoint", uploadUrl), new JProperty("params", new JObject(new JProperty("folder", uploadFolder ?? ""))))), new JProperty("text", new JObject(new JProperty("uploadButton", "<i class=\"fa fa-lg fa-upload\"></i>"))), new JProperty("template", string.Format("<div class=\"input-group\"><input type=\"text\" class=\"form-control\" name=\"{0}\" id=\"{1}\" value=\"{2}\" autocomplete=\"off\" data-val=\"{4}\" data-val-required=\"{5}\" /><div class=\"input-group-btn\"><div class=\"qq-upload-drop-area\"><span>{{dragZoneText}}</span></div><div class=\"btn btn-default qq-upload-button\">{{uploadButtonText}}</div>{3}</div></div><div class=\"qq-drop-processing\"><span>{{dropProcessingText}}</span><span class=\"qq-drop-processing-spinner\"></span></div><div class=\"qq-upload-list\"></div>", Name, id, Value, browseButton, Required.ToString().ToLowerInvariant(), Constants.Messages.Validation.Required)), new JProperty("fileTemplate", "<div><div class=\"qq-progress-bar hide\"></div><span class=\"qq-upload-spinner\"></span><span class=\"qq-upload-file hide\"></span><span class=\"qq-upload-size\"></span><a class=\"qq-upload-cancel\" href=\"#\">{cancelButtonText}</a><span class=\"qq-upload-status-text\">{statusText}</span></div>"), }; var sb = new StringBuilder(); sb.AppendFormat("<div class=\"{1}\" id=\"{0}_Container\"></div>", id, CssClass); if (Required) { sb.AppendFormat("<span data-valmsg-for=\"{0}\" data-valmsg-replace=\"true\"></span>", Name); } if (ShowThumbnail) { if (Value != null) { sb.AppendFormat("<a href=\"{0}\" target=\"_blank\" title=\"Click to view larger image\"><img src=\"{0}\" data-src=\"holder.js/128x128\" style=\"max-width: 128px; max-height: 128px; margin-top: 5px;\" /></a>", Value); } } var scriptRegister = new ScriptRegister(workContext); scriptRegister.IncludeInline(string.Format("$('#{0}_Container').fineUploader({1}).on('upload', function(){{ var f = document.getElementById('{0}').form; var o ={{}};var a = $(f).serializeArray(); $.each(a, function(){{ if(o[this.name] !== undefined){{ if(!o[this.name].push){{ o[this.name]=[o[this.name]]; }} o[this.name].push(this.value || ''); }}else{{ o[this.name] = this.value || '';}} }}); $(this).fineUploader('setParams', o); }}).on('complete', function(event, id, name, responseJSON){{ if(responseJSON.success){{ $('#{0}').val(responseJSON.mediaUrl); }} else {{ $('#{0}').val(''); }} }}).on('complete', function(){{ $('#{0}_Container .qq-upload-list').hide(); }});", id, clientOptions.ToString(Formatting.None))); return(sb.ToString()); }
public XmlNode GenerateXML() { // Create XML Node and Attributes XmlDocument d = new XmlDocument(); XmlNode output = d.CreateNode("element", "InputText", null); XmlAttribute adValidate = d.CreateAttribute("ADValidate"); XmlAttribute _default = d.CreateAttribute("Default"); XmlAttribute forceCase = d.CreateAttribute("ForceCase"); XmlAttribute hint = d.CreateAttribute("Hint"); XmlAttribute hScroll = d.CreateAttribute("HScroll"); XmlAttribute password = d.CreateAttribute("Password"); XmlAttribute prompt = d.CreateAttribute("Prompt"); XmlAttribute question = d.CreateAttribute("Question"); XmlAttribute regEx = d.CreateAttribute("RegEx"); XmlAttribute required = d.CreateAttribute("Required"); XmlAttribute variable = d.CreateAttribute("Variable"); XmlAttribute condition = d.CreateAttribute("Condition"); // Set Attribute Values adValidate.Value = ADValidate; _default.Value = Default; forceCase.Value = ForceCase; hint.Value = Hint; hScroll.Value = HScroll.ToString(); password.Value = Password.ToString(); prompt.Value = Prompt; question.Value = Question; regEx.Value = RegEx; required.Value = Required.ToString(); variable.Value = Variable; condition.Value = Condition; // Append Attributes if (!string.IsNullOrEmpty(ADValidate)) { output.Attributes.Append(adValidate); } if (!string.IsNullOrEmpty(Default)) { output.Attributes.Append(_default); } if (!string.IsNullOrEmpty(ForceCase)) { output.Attributes.Append(forceCase); } if (!string.IsNullOrEmpty(Hint)) { output.Attributes.Append(hint); } if (null != HScroll) { output.Attributes.Append(hScroll); } if (null != Password) { output.Attributes.Append(password); } if (!string.IsNullOrEmpty(Prompt)) { output.Attributes.Append(prompt); } if (!string.IsNullOrEmpty(Question)) { output.Attributes.Append(question); } if (!string.IsNullOrEmpty(RegEx)) { output.Attributes.Append(regEx); } if (null != Required) { output.Attributes.Append(required); } if (!string.IsNullOrEmpty(Variable)) { output.Attributes.Append(variable); } if (!string.IsNullOrEmpty(Condition)) { output.Attributes.Append(condition); } return output; }
internal override void CreateField(SPList list) { if (!list.Fields.ContainsFieldWithStaticName(InternalName)) { list.Fields.AddFieldAsXml(string.Format("<Field Type=\"UserMulti\" DisplayName=\"{0}\" List=\"UserInfo\" ShowField=\"ImnName\" Required=\"{1}\" UserSelectionMode=\"{2}\" UserSelectionScope=\"{3}\" Mult=\"TRUE\" Sortable=\"FALSE\" />", InternalName, Required.ToString().ToUpperInvariant(), SelectionMode, SelectionGroup), false, SPAddFieldOptions.Default); } var field = (SPFieldUser)list.Fields.GetFieldByInternalName(InternalName); field.Description = Description; field.SelectionMode = SelectionMode; field.AllowMultipleValues = AllowMultipleValues; if (!string.IsNullOrEmpty(ShowField)) { field.LookupField = ShowField; } else { field.LookupField = "ImnName"; } if (SelectionGroup > 0) { field.SelectionGroup = SelectionGroup; } if (EnforceUniqueValues) { field.Indexed = true; field.EnforceUniqueValues = true; } field.Title = Name; field.AllowDeletion = true; field.Update(); }