Make HtmlHelper public in class Bootstrap<TModel>


Public HtmlHelper is important for creating own extension methods for Bootstrap<TModel> class.


DmitryEfimenko wrote May 15, 2013 at 6:12 PM

Agree, I'll make that change.
You also might consider sharing your ideas on your own extensions if you think it could be useful for these to be included in TwitterBootstrapMVC for other people as well.

topas wrote May 15, 2013 at 7:04 PM


Thank you for this very useful library. It is the best I have see in last time. Code in views is more clear and readable!

I am thinking about some extension methods for Container something like Span1, Span2, etc for better layouting, helpers for forms: BeginHorizontalForm, BeginInlineForm with same parameters as Html.BeginForm also with T4MVC overloads. I am missing something for creating listboxes too.

I found also some issue if I want create login horizontal form without labels (only with prepend icons). My workaround was simple: Bootstrap.ControlGroup().TextboxFor(...).Label().HtmlAttributes(style = "display:none").


DmitryEfimenko wrote May 15, 2013 at 8:57 PM

Would the following syntax work or do you have any other suggestions?
@using(Html.Bootstrap().Container().BeginHorizontalForm(...) { }
@using(Html.Bootstrap().Container().BeginInlineForm(...) { }
@using(Html.Bootstrap().Container().Span(4) { }
What do you mean by "listboxes"? Do you mean creating checkboxes for IEnumerable<T>? If so, there are methods already built to cover these: .CheckboxListFor(...)

Regarding the issue you mentioned... could you show me an example of html output that you are seeking to be generated?

DmitryEfimenko wrote May 16, 2013 at 4:36 AM

Another option appeared on a horizon.
Please see this post.

topas wrote May 16, 2013 at 10:34 AM


the second option for creating forms is great! And, please, do not forget make public some base interface (probably something like IDisposable with some Render(HtmlHelper) method) - and everybody will be able to create own container render helpers. I like it!

Listboxes... I mean same thing as Html.ListboxFor() does: <select multiple="multiple">. I know it is very similar to list of checkboxes but I am using select2 and its "tag" feature for this use case.

Ad issue with label: I want to create textbox in controlgroup without label. Something like:
<div class="control-group">
<div class="controls">
    <input data-val="true" data-val-required="'Username' must not be empty." id="LoginUsername" name="LoginUsername" placeholder="Username" type="text" value="">
    <span class="help-inline">
        <span class="field-validation-valid" data-valmsg-for="LoginUsername" data-valmsg-replace="true"></span>
If I try emptry string as parameter for label's text I got default value. I think some way how to get control in controlgroup without label will be nice.