コード例 #1
0
        public static ModalBuilder Modal(this BootstrapFactory factory, string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("id");
            }

            return(new ModalBuilder().Id(id));
        }
コード例 #2
0
        public static MvcForm BeginForm(this BootstrapFactory factory, Action <FormBuilder> configuration)
        {
            var builder = new FormBuilder(factory.HtmlHelper);

            if (configuration != null)
            {
                configuration(builder);
            }
            return(builder.Build());
        }
コード例 #3
0
 public static MvcForm BeginForm(this BootstrapFactory factory, string actionName, string controllerName, RouteValueDictionary routeValues, Action <FormBuilder> configuration)
 {
     return(factory.BeginForm(c =>
     {
         var url = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues, factory.HtmlHelper.RouteCollection,
                                         factory.HtmlHelper.ViewContext.RequestContext, true);
         c.Url(url);
         if (configuration != null)
         {
             configuration(c);
         }
     }));
 }
コード例 #4
0
        private static InputBuilder UnobtrusiveValidationAttributes <TModel, TProperty>(this BootstrapFactory <TModel> factory, InputBuilder builder, Expression <Func <TModel, TProperty> > expression)
        {
            var htmlHelper = factory.HtmlHelper;

            var name = ExpressionHelper.GetExpressionText(expression);

            var fullHtmlFieldName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);

            var modelMetadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
            var attributes    = htmlHelper.GetUnobtrusiveValidationAttributes(name, modelMetadata);

            var value = htmlHelper.FormatValue(modelMetadata.Model, null);

            builder.Id(fullHtmlFieldName).Name(fullHtmlFieldName).Value(value);

            foreach (var attribute in attributes)
            {
                builder.Attribute(attribute.Key, attribute.Value.ToString(), true);
            }

            return(builder);
        }
コード例 #5
0
 public static InputBuilder PasswordFor <TModel, TProperty>(this BootstrapFactory <TModel> factory, Expression <Func <TModel, TProperty> > expression)
 {
     return(factory.UnobtrusiveValidationAttributes(factory.Password(), expression));
 }
コード例 #6
0
 public static InputBuilder Password(this BootstrapFactory factory)
 {
     return(new InputBuilder().Type().Password());
 }
コード例 #7
0
 public static InputBuilder TextBox(this BootstrapFactory factory)
 {
     return(new InputBuilder().Type().Text());
 }
コード例 #8
0
 public static MvcForm BeginForm(this BootstrapFactory factory,
                                 string actionName, string controllerName, Action <FormBuilder> configuration)
 {
     return(factory.BeginForm(actionName, controllerName, new RouteValueDictionary(), configuration));
 }
コード例 #9
0
 public static ModalBuilder Modal(this BootstrapFactory factory)
 {
     return(factory.Modal(Guid.NewGuid().ToString("N")));
 }