I'm creating an MVC 5 site using bootstrap 3.0.0. I'm having difficulty binding the model to an input field. I simply don't know the syntax for doing this.
The following code works functionally, but I lose bootstrap's styling.
<div class="control-group">
@Html.LabelFor(model => model.Name, new { @class = "control-label" })
<div class="controls">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
</div>
On the other hand, this block of code looks great, but I can't get the binding to work. @using (Html.BeginForm()) {
<div class="input-group">
<span class="input-group-addon">@Html.LabelFor(model => model.Name)</span>
<input type="text" class="form-control" placeholder="Enter your name here..."/>
<span class="input-group-addon">@Html.ValidationMessageFor(model => model.Name)</span>
</div>
<div class="form-actions no-color">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</fieldset>
}
So I need some assistance either getting the top block or bottom block to work. Either the right syntax to make it work functionally, or a slick method of attaching to the correct CSS in bootstrap to make it look attractive.
Any suggestions are welcome.