Asp.NET MVC Html Extensions Samples
-
Using modular and re-useable code always takes a lot of overhead over shoulders. By extending existing MVC Helper classes following benefits can be achieved:
- Simplify Html code and keep view cleaner.
- Combine several lines of Html in a single Helper
- Create clean code on view
In this sample, Asp.NET project, there are some Html Extension helper classes and methods created.
--------------------------- You can see Html Helper method samples under "Components" folder.Usage Example:
Helper.Image("imagelink", "alt", new { class ="img-responsive" } )
There are different overload methods available.
Custom bootstrap button helper extensions.
Custom bootstrap textbox and form field helper extensions.
Usage Example:
@Html.FormFieldTextBoxFor(x => x.Team, HtmlExtensions.HmlExtensionsCommon.InputTypes.text, new { @class = "form-control" })
FormFieldTextBoxFor adds TextBox with Label in Bootstrap style. Label value is read from expression property name or Custom Data Attribute if exists.
Custom bootstrap style checkbox extensions.
Bootstrap customizable image box.
Usage Example:
@Html.ImageBoxFor(x => x.Image, "", "logo-barca", true, HmlExtensionsCommon.ImageTypes.roundedCorners, new { @title="Barcelona City"})