示例#1
0
        public static HtmlTag ValidationText <T>(this HtmlHelpers <T> html, string name)
        {
            return(HtmlTag.Empty());

            var result = html.RenderContext.Context.ModelValidationResult;

            if (result.IsValid)
            {
                return(HtmlTag.Empty());
            }
            if (!result.Errors.ContainsKey(name))
            {
                return(HtmlTag.Empty());
            }
            var error = result.Errors[name];

            if (error.Count == 0)
            {
                return(HtmlTag.Empty());
            }
            var tag = new DivTag();

            tag.Text(error[0]);
            return(tag.AddClass("error"));
        }
示例#2
0
        private HtmlTag buildHtmlForTasks(IEnumerable <Task> tasks)
        {
            var rootTag = new DivTag("tasks");
            var ul      = new HtmlTag("ul");

            tasks.OrderBy(x => x.ScheduledDate).Each(x =>
            {
                var li    = new HtmlTag("li");
                var liDiv = new DivTag("liDiv");
                var task  = x.ScheduledDate.Value.ToLongDateString() + " " + x.ScheduledStartTime.Value.ToShortTimeString();
                task     += x.ScheduledEndTime.HasValue? " To " + x.ScheduledEndTime.Value.ToShortTimeString():"";
                task     += ": " + x.TaskType.Name + " at " + x.Field.Name;
                liDiv.Text(task);
                li.AddChildren(liDiv);
                ul.AddChildren(li);
            });
            rootTag.AddChildren(ul);
            return(rootTag);
        }