public static ModalBuilder Modal(this BootstrapFactory factory, string id) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("id"); } return(new ModalBuilder().Id(id)); }
public static MvcForm BeginForm(this BootstrapFactory factory, Action <FormBuilder> configuration) { var builder = new FormBuilder(factory.HtmlHelper); if (configuration != null) { configuration(builder); } return(builder.Build()); }
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); } })); }
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); }
public static InputBuilder PasswordFor <TModel, TProperty>(this BootstrapFactory <TModel> factory, Expression <Func <TModel, TProperty> > expression) { return(factory.UnobtrusiveValidationAttributes(factory.Password(), expression)); }
public static InputBuilder Password(this BootstrapFactory factory) { return(new InputBuilder().Type().Password()); }
public static InputBuilder TextBox(this BootstrapFactory factory) { return(new InputBuilder().Type().Text()); }
public static MvcForm BeginForm(this BootstrapFactory factory, string actionName, string controllerName, Action <FormBuilder> configuration) { return(factory.BeginForm(actionName, controllerName, new RouteValueDictionary(), configuration)); }
public static ModalBuilder Modal(this BootstrapFactory factory) { return(factory.Modal(Guid.NewGuid().ToString("N"))); }