Extendable packages pack for simplifying Bootstrap markup in your ASP.MVC projects.
alpha.3
, not complete at this moment), not bound to any MVC version;Bootstrap 3
in your ASP.NET Core / MVC6 projects.Bootstrap 4
in your ASP.NET Core / MVC6 projects.
TextWriter-s
, minimizing String allocation and concatenation;Just one sample - input form. Do you remember how much markup you should write? Now you can:
using (var form = Bootstrap.BeginFormFormType.Horizontal))
{
using (Bootstrap.BeginFormFieldset("Fieldset one"))
{
@Bootstrap.FormGroupFor(m => m.StringField)
.Label("Label 1")
.Control(Bootstrap.Input().Placeholder("placeholder text"))
}
using (form.BeginFieldset("Fieldset two"))
{
@form.GroupFor(m => m.IntegerField, "Label 2")
.Control(Bootstrap.InputInt().Size(0, 3, 3, 3, 3))
@form.GroupFor(m => m.BooleanField)
.Control(Bootstrap.Checkbox("checkbox text"))
}
using (form.Group().BeginContent())
{
@Bootstrap.Button(ButtonType.SuccessGreen, "Save")
@Bootstrap.Button(ButtonType.SecondaryWhite, "Cancel").Href("/list")
}
}
And you got this:
For more samples, visit one of sites: for Bootstrap 3 in ASP.NET MVC5 or for Bootstrap 3 in ASP.NET Core / MVC6 or even for Bootstrap 4 alpha.3 in ASP.NET Core / MVC6
Install BootstrapMvc.Bootstrap3Mvc5 package from NuGet to your ASP.MVC5 project.
Views\web.config
fileModify your Views\Web.config
file (and all Areas\<Area>\Views\Web.config
too), replace base class for views (in <system.web.webPages.razor>
section), instead:
<pages pageBaseType="System.Web.Mvc.WebViewPage">
write
<pages pageBaseType="BootstrapMvc.Core.BootstrapViewPage">
And add one more namespace
to namespaces list:
<add namespace="BootstrapMvc" />
Clean and Rebuild you project to activate changes and activate intellisence. Rarely, a Visual Studio restart also needed.
project.json
"dependencies": {
...
"BootstrapMvc.Bootstrap3Mvc6": "2.3.0"
}
"dependencies": {
...
"BootstrapMvc.Bootstrap4Mvc6": "1.0.0-*"
}
RTM build of ASP.NET Core / MVC6 is supported.
Views\_ViewImports.cshtml
fileAdd two lines to Views\_ViewImports.cshtml
file (create it if not exists):
@using BootstrapMvc
@inject BootstrapMvc.Mvc6.BootstrapHelper<TModel> Bootstrap
Append to ConfigureServices()
method in Startup.cs
file:
services.AddTransient(typeof(BootstrapMvc.Mvc6.BootstrapHelper<>));