daveaglick / FluentBootstrap

Provides extensions, helper classes, model binding, and other goodies to help you use the Bootstrap CSS framework from .NET code.
http://www.fluentbootstrap.com
MIT License
200 stars 76 forks source link

How can I get HtmlHelper from BootstrapConfig? #70

Closed fairking closed 7 years ago

fairking commented 7 years ago

Hi everyone.

I'm writing some extensions for my project to simplify my views and to make fluent bootstrap more flexible. 20161116_1657

How can I get HtmlHelper from FB Config? As I can see it's not a public property helper.GetConfig().HtmlHelper.

Thanks.

daveaglick commented 7 years ago

There's extensions to help with this. They're hidden inside a special namespace so that normal consumers don't accidentally see them and get confused. Just add using FluentBootstrap.Mvc.Internals; to the top of your file to bring the extensions into scope and you should be able to write something like helper.GetConfig().GetHtmlHelper() to get your typed HtmlHelper<TModel>.

As a little side note, the way that HtmlHelper<TModel> stores the model type for the view is the whole reason FluentBootstrap needs all these crazy generics. The underlying FluentBootstrap code would be so much simpler if it weren't for the need to carry that model type with us everywhere.