当前位置: 首页>>代码示例>>C#>>正文


C# HtmlTag.Data方法代码示例

本文整理汇总了C#中HtmlTags.HtmlTag.Data方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.Data方法的具体用法?C# HtmlTag.Data怎么用?C# HtmlTag.Data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlTags.HtmlTag的用法示例。


在下文中一共展示了HtmlTag.Data方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddRegexData

 public void AddRegexData(IEnumerable<ValidationAttribute> propertyValidators, HtmlTag htmlTag, RequestData request)
 {
     var regex = propertyValidators.OfType<RegularExpressionAttribute>().FirstOrDefault();
     if (regex != null)
     {
         var msg = regex.ErrorMessage ?? string.Format("The field '{0}' did not match the regular expression '{1}'", request.Accessor.InnerProperty.Name, regex.Pattern);
         if (_msUnobtrusive)
             htmlTag.Data("val", true).Data("val-regex", msg).Data("val-regex-pattern", regex.Pattern);
         else
             htmlTag.Data("rule-regex", regex.Pattern).Data("msg-regex", msg);
     }
 }
开发者ID:eByte23,项目名称:SchoStack,代码行数:12,代码来源:DataAnnotationValidationHtmlConventions.cs

示例2: Run

 /// <summary>
 /// Run the specified validator, tag and formattedMessage.
 /// </summary>
 /// <param name="validator">A validator.</param>
 /// <param name="tag">A tag.</param>
 /// <param name="formattedMessage">Formatted message.</param>
 public void Run(FluentValidation.Validators.IPropertyValidator validator, HtmlTag tag, string formattedMessage)
 {
     if (validator is CpfValidator)
     {
         tag.Data("val-cpf", formattedMessage);
     }
     else if (validator is ValidDate)
     {
         tag.Data("val-dateBR", formattedMessage);
     }
     else if (validator is ValidNomeConjuge)
     {
         tag.Data("val-nomeConjuge", formattedMessage);
     }
 }
开发者ID:GestUAB,项目名称:GestUAB,代码行数:21,代码来源:ValidatorCommand.cs

示例3: Modify

        public virtual void Modify(HtmlTag form)
        {
            if (!_modify) return;

            form.Data("validation-mode", _value.ToLower());
            form.AddClass("validated-form");
        }
开发者ID:emiaj,项目名称:fubuvalidation,代码行数:7,代码来源:ValidationMode.cs

示例4: AddEqualToDataAttr

 public void AddEqualToDataAttr(IEnumerable<ValidationAttribute> propertyValidators, HtmlTag htmlTag, RequestData request)
 {
     var equal = propertyValidators.OfType<CompareAttribute>().FirstOrDefault();
     if (equal != null)
     {
         var formatErrorMessage = equal.FormatErrorMessage(request.Accessor.Name);
         if (_msUnobtrusive)
         {
             htmlTag.Data("val", true);
             htmlTag.Data("val-equalto", formatErrorMessage);
             if (request.Accessor.PropertyNames.Length > 1)
             {
                 htmlTag.Data("val-equalto-other", request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.OtherProperty);
             }
             else
             {
                 htmlTag.Data("val-equalto-other", "*." + equal.OtherProperty);
             }
         }
         else
         {
             htmlTag.Data("msg-equalto", formatErrorMessage);
             if (request.Accessor.PropertyNames.Length > 1)
                 htmlTag.Data("rule-equalto", "#" + request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.OtherProperty);
             else
                 htmlTag.Data("rule-equalto", "#" + equal.OtherProperty);
         }
     }
 }
开发者ID:eByte23,项目名称:SchoStack,代码行数:29,代码来源:DataAnnotationValidationHtmlConventions.cs

示例5: AddEqualToDataAttr

        public void AddEqualToDataAttr(IEnumerable<PropertyValidatorResult> propertyValidators, HtmlTag htmlTag, RequestData request)
        {
            var result = propertyValidators.FirstOrDefault(x => x.PropertyValidator is EqualValidator);
            if (result != null)
            {
                var equal = result.PropertyValidator.As<EqualValidator>();
                MessageFormatter formatter = new MessageFormatter()
                    .AppendPropertyName(result.DisplayName)
                    .AppendArgument("ComparisonValue", equal.ValueToCompare);

                string message = formatter.BuildMessage(equal.ErrorMessageSource.GetString());

                if (_msUnobtrusive)
                {
                    htmlTag.Data("val", true);
                    htmlTag.Data("val-equalto", message);
                    if (request.Accessor.PropertyNames.Length > 1)
                        htmlTag.Data("val-equalto-other", request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.MemberToCompare.Name);
                    else
                        htmlTag.Data("val-equalto-other", "*." + equal.MemberToCompare.Name);
                }
                else
                {
                    htmlTag.Data("msg-equalto", message);
                    if (request.Accessor.PropertyNames.Length > 1)
                        htmlTag.Data("rule-equalto", "#" + request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.MemberToCompare.Name);
                    else
                        htmlTag.Data("rule-equalto", "#" + equal.MemberToCompare.Name);
                }
            }
        }
开发者ID:eByte23,项目名称:SchoStack,代码行数:31,代码来源:FluentValidationHtmlConventions.cs

示例6: AddCreditCardClass

 public void AddCreditCardClass(IEnumerable<PropertyValidatorResult> propertyValidators, HtmlTag htmlTag, RequestData requestData)
 {
     var lengthValidator = propertyValidators.Select(x => x.PropertyValidator).OfType<CreditCardValidator>().FirstOrDefault();
     if (lengthValidator != null)
     {
         if (requestData.ViewContext.UnobtrusiveJavaScriptEnabled)
         {
             if (!_msUnobtrusive)
             {
                 htmlTag.Data("rule-creditcard", true);
             }
         }
         else
         {
             htmlTag.AddClass("creditcard");
         }
     }
 }
开发者ID:schotime,项目名称:SchoStack,代码行数:18,代码来源:FluentValidationHtmlConventions.cs

示例7: AddRequiredClass

 public void AddRequiredClass(IEnumerable<ValidationAttribute> propertyValidators, HtmlTag htmlTag, RequestData request)
 {
     var required = propertyValidators.OfType<RequiredAttribute>().FirstOrDefault();
     if (required != null)
     {
         if (request.ViewContext.UnobtrusiveJavaScriptEnabled)
         {
             var msg = required.ErrorMessage ?? string.Format("The field '{0}' is required", request.Accessor.InnerProperty.Name);
             if (_msUnobtrusive)
                 htmlTag.Data("val", true).Data("val-required", msg);
             else
                 htmlTag.Data("rule-required", true).Data("msg-required", msg);
         }
         else 
             htmlTag.AddClass("required");
     }
 }
开发者ID:eByte23,项目名称:SchoStack,代码行数:17,代码来源:DataAnnotationValidationHtmlConventions.cs

示例8: AddEmailData

 public void AddEmailData(IEnumerable<PropertyValidatorResult> propertyValidators, HtmlTag htmlTag, RequestData requestData)
 {
     var result = propertyValidators.FirstOrDefault(x => x.PropertyValidator is EmailValidator);
     if (result != null)
     {
         if (requestData.ViewContext.UnobtrusiveJavaScriptEnabled)
         {
             var msg = GetMessage(requestData, result) ?? string.Format("The value is not a valid email address");
             if (_msUnobtrusive)
                 htmlTag.Data("val", true).Data("val-email", msg);
             else
                 htmlTag.Data("rule-email", true).Data("msg-email", msg);
         }
         else
             htmlTag.AddClass("email");
     }
 }
开发者ID:schotime,项目名称:SchoStack,代码行数:17,代码来源:FluentValidationHtmlConventions.cs

示例9: AddRequiredClass

        public void AddRequiredClass(IEnumerable<PropertyValidatorResult> propertyValidators, HtmlTag htmlTag, RequestData requestData)
        {
            var result = propertyValidators.FirstOrDefault(x => x.PropertyValidator is NotEmptyValidator
                                                             || x.PropertyValidator is NotNullValidator);

            if (result != null)
            {
                if (requestData.ViewContext.UnobtrusiveJavaScriptEnabled)
                {
                    if (_msUnobtrusive)
                        htmlTag.Data("val", true).Data("val-required", GetMessage(requestData, result) ?? string.Empty);
                    else
                        htmlTag.Data("rule-required", true).Data("msg-required", GetMessage(requestData, result) ?? string.Empty);
                }
                else
                    htmlTag.AddClass("required");
            }
        }
开发者ID:schotime,项目名称:SchoStack,代码行数:18,代码来源:FluentValidationHtmlConventions.cs

示例10: AddRegexData

        public void AddRegexData(IEnumerable<PropertyValidatorResult> propertyValidators, HtmlTag htmlTag, RequestData requestData)
        {
            var result = propertyValidators.FirstOrDefault(x => x.PropertyValidator is RegularExpressionValidator);

            if (result != null && requestData.ViewContext.UnobtrusiveJavaScriptEnabled)
            {
                var regex = result.PropertyValidator.As<RegularExpressionValidator>();
                var msg = GetMessage(requestData, result) ?? string.Format("The value did not match the regular expression '{0}'", regex.Expression);
                if (_msUnobtrusive)
                    htmlTag.Data("val", true).Data("val-regex", msg).Data("val-regex-pattern", regex.Expression);
                else
                    htmlTag.Data("rule-regex", regex.Expression).Data("msg-regex", msg);
            }
        }
开发者ID:schotime,项目名称:SchoStack,代码行数:14,代码来源:FluentValidationHtmlConventions.cs


注:本文中的HtmlTags.HtmlTag.Data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。