dev.reddin.BootstrapHtmlHelpers 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package dev.reddin.BootstrapHtmlHelpers --version 0.0.1
                    
NuGet\Install-Package dev.reddin.BootstrapHtmlHelpers -Version 0.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="dev.reddin.BootstrapHtmlHelpers" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="dev.reddin.BootstrapHtmlHelpers" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="dev.reddin.BootstrapHtmlHelpers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add dev.reddin.BootstrapHtmlHelpers --version 0.0.1
                    
#r "nuget: dev.reddin.BootstrapHtmlHelpers, 0.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package dev.reddin.BootstrapHtmlHelpers@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=dev.reddin.BootstrapHtmlHelpers&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=dev.reddin.BootstrapHtmlHelpers&version=0.0.1
                    
Install as a Cake Tool

Bootstrap HTML Helpers

Extensions for IHtmlHelper<TModel> that makes building Bootstrap forms mapped to MVC models super easy. Features:

  • Each component is placed in a form group Div with Bootstrap class mb-3
  • Support for validation and error messages
  • Support for DisplayAttribute, including Name, Prompt, and Description (which is rendered below in a div element with the CSS class form-text).

Example

Given the following model:

public class ExampleViewModel
{
    [Display(Prompt = "Placeholder", Description = "Property description")]
    [Required(ErrorMessage = "Invalid message")]
    public string ModelProperty { get; set; }
}

To build a simple text box:

@Html.BsTextBoxFor(m => m.ModelProperty)

With the model state calculated to be invalid, the above renders out to:

<div class="mb-3">
    <label class="form-label" for="Name">Name</label>
    <input class="form-control is-invalid " data-val="true" data-val-required="Invalid message" id="Name" name="Name" placeholder="Placeholder" type="text" value="">
    <div class="invalid-feedback field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true">
        Invalid messge
    </div>
    <div class="form-text">
        Property description
    </div>
</div>

All components

Basic textbox:

@Html.BsTextBoxFor(m => m.ModelProperty)

Textbox for passwords:

@Html.BsPasswordFor(m => m.ModelPropety)

Datepicker:

@Html.BsDatePickerFor(m => m.ModelProperty)

Yes/No Radio button group. This renders a group of radio buttons for boolean values. By default the layout is horizontal, but if you'd rather have a vertical layout for this control, add RadioButtonLayout.Vertical

@Html.BsYesNoFor(m => m.BooleanModelProperty)
@Html.BsYesNoFor(m => m.BooleanModelProperty, RadioButtonLayout.Vertical) @* vertical layout *@

Checkbox for boolean values:

@Html.BsCheckboxFor(m => m.BooleanModelProperty)

<select> dropdown for any list of strings:

@Html.BsDropDownListFor(m => m.Name, new List<SelectListItem> {
    new SelectListItem { Value = "value1", Text = "Display Value 1" },
    new SelectListItem { Value = "value2", Text = "Display Value 2" }, 
    new SelectListItem { Value = "value3", Text = "Display Value 3" } 
})

<select> dropdown for enums. This uses the built in IHtmlHelper<TModel>.GetEnumSelectList<TEnum>() method so this supports DisplayAttribute.Name right out of the box.

@Html.BsEnumDropDownListFor(m => m.EnumModelProperty)

If the enum property is nullable and a blank option is required, use:

@Html.BsNullableEnumDropDownListFor(m => m.NullableEnumModelProperty)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.22 246 3/11/2025
0.0.21 151 2/26/2025
0.0.20 158 12/3/2024
0.0.19 158 9/25/2024
0.0.18 148 9/20/2024
0.0.17 174 8/16/2024
0.0.16 150 8/16/2024
0.0.15 162 5/10/2024
0.0.14 196 3/4/2024
0.0.13 173 2/22/2024
0.0.12 163 2/22/2024
0.0.11 156 2/19/2024
0.0.10 158 2/18/2024
0.0.9 164 2/15/2024
0.0.8 203 2/10/2024
0.0.7 182 1/21/2024
0.0.6 176 1/21/2024
0.0.5 206 1/6/2024
0.0.4 182 1/5/2024
0.0.3 185 12/28/2023
0.0.2 176 12/24/2023
0.0.1 165 12/24/2023