DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
221 stars 78 forks source link

Changes to "Div()" #404

Open AlonCG opened 9 years ago

AlonCG commented 9 years ago

In the latest release ... 3.16.4 ... there are the following changes related to the "Div()" method:

  1. .Div() method now has extensions to specify its offset. Ex: .XsOffset(5)
  2. .Div() method now accepts a string as a parameter

Regarding item 2 above, can you explain what string is to be put as the parameter? My calls to ".Div()" now break, so I put in an empty string ("") for now, but would like to know what should actually go there.

Thanks! All the best.

AlonCG commented 9 years ago

Maybe I am using "Div()" incorrectly ...

@Html.Bootstrap().Div().HtmlAttributes(new { style = "margin-top:5px;" })

I need to see why I was doing that in the first place, but it just looks like I had a placeholder "Div" to add some spacing (inside a tabs.BeginPanel()) ... This may be a moot issue.

DmitryEfimenko commented 9 years ago

I'm surprised @Html.Bootstrap().Div() worked before! The intend for the helper method is to wrap any content you like. Before it only used to take IHtmlString, so you could write the following:

@Html.Bootstrap().Div(Html.Bootstrap().TextBoxFor(m => m,UserName))

... and that would output:

<div>
    <input type="text" name="UserName" [and all the rest attrs] />
</div>

In that particular example there isn't much benefit of using .Div(), but it's got Bootstrap related extensions and other BMVC methods that you are used to (I'm sure you are aware of these since you used one in your example). Now you can pass in any string. Could be Html string or just text:

@Html.Bootstrap().Div("<div>any html here</div>").Sm(3)
@Html.Bootstrap().Div("any text here").Sm(4)

I could add an override that does not take any parameters and outputs an empty div - just like you used to use it. Let me know if you'd like that be done.