Collection of HtmlHelpers and other sweet things
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vs/config Updated aspnet nuget packages Oct 16, 2018
MVCSugar.Samples Updated aspnet nuget packages Oct 16, 2018
MVCSugar
.gitattributes Initial commit Sep 20, 2014
.gitignore Updated aspnet nuget packages Oct 16, 2018
LICENSE Initial commit Sep 20, 2014
MVCSugar.sln
README.md Added ImageFor documentation Oct 21, 2017

README.md

MVCSugar

Collection of HtmlHelpers and other sweet things

This is an early release of some HTMLHelpers that we find ourselves using across multiple projects.

You can get the latest release from NuGet.

Install-Package RedWall.MVCSugar

SessionHelper

SessionHelper.Add(string key, object value) Simple wrapper around storing the specified value with the provided key in the session object.

SessionHelper.Get<T>(string key) Retrieves the value from the session object with the specified key and casts the object to the type specified in the T generic parameter.

SessionHelper.Get<T>(string key, Func<T> getIfEmpty) Retrieves the value from the session object with the specified key and casts the object to the type specified in the T generic parameter. If there is no object in session with the specified key the getIfEmpty function will be executed and the return value will be stored in session and then returned to the caller.

ValidateReCaptchaAttribute

[ValidateReCaptcha(RecaptchaSecret="<secret>")]

Automatically validates a ReCaptcha when applied to an MVC Controller. Must provide the RecapchaSecret when applying the attribute.

Will add a ReCaptcha ModelState error if the validation fails.

HtmlHelpers

EnumDisplay, EnumDisplayFor, and EnumDisplayNameFor See http://stronglikebool.com/2014/09/20/enum-support-in-mvc-5_1/

@Html.ImageFor(m => m.ImageAsByteArray) Will take a model property that is an image stored as a byte[] and will render an <img> HTML element with an inline base64 encoded image.