DmitryEfimenko / TwitterBootstrapMvc

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

Can not set name propery on control (e.g. TextBoxFor) #421

Closed markusgud closed 8 years ago

markusgud commented 8 years ago

I am using this code in the cshtml file: @f.FormGroup().TextBoxFor(x => x.Value).Id(Model.DataNode+"_Value").Label().LabelText(Model.Label)

But I can not find a way to set the name property, I would like to see its value set to control.Controls[1].Adddress_Value.

<div class=" form-group"><label class="control-label col-lg-2" for="control_Controls_1__Value">Heimilisfang<span class="required">*</span> </label><div class="col-lg-10"><input class="form-control" id="Address_Value" name="control.Controls[1].Value" type="text" value="" /><span class="field-validation-valid" data-valmsg-for="control.Controls[1].Value" data-valmsg-replace="true"></span></div></div>

How can this be accomplished?

Markús

DmitryEfimenko commented 8 years ago

You can use helper method .HtmlAttributes() to set any attribute just like in regular MVC TextBox.

f.FormGroup().TextBoxFor(x => x.Value).HtmlAttributes(new { @name = "my-name" })
markusgud commented 8 years ago

Thank you. Splendid. It works.