Exemplo n.º 1
0
        public static IHtmlString ValidationMessage <TModel>(this HtmlHelpers <TModel> htmlHelper, string propertyName)
        {
            var errorsForField = htmlHelper.GetErrorsForProperty(propertyName).ToList();

            if (!errorsForField.Any())
            {
                return(new NonEncodedHtmlString(String.Empty));
            }

            return(new NonEncodedHtmlString(errorsForField.First().GetMessage(propertyName)));
        }
Exemplo n.º 2
0
        private static IHtmlString InputHelper <TModel>(HtmlHelpers <TModel> htmlHelper, string inputType, string propertyName, string value, string className, string placeholder)
        {
            bool hasError = htmlHelper.GetErrorsForProperty(propertyName).Any();

            return(new NonEncodedHtmlString(String.Format(InputTemplate, inputType, propertyName, propertyName, value, hasError ? String.Format("{0} {1}", className, "error").Trim() : className, placeholder)));
        }