You need to use helper methods so that MVC knows how to bind values, and then in the controller you can use the model (since you will understand the modelβs connecting device)
eg.
@model Models.AuthForm @{ ViewBag.Title = ""; } @section home { @using (Html.BeginForm("Auth", "Controller")) { <div class="control-group"> @Html.LabelFor(model => model.Login, new { @class = "control-label" }) <div class="controls"> @Html.TextBoxFor(model => model.Login, new { @class = "input-large", autocapitalize = "off" }) @Html.ValidationMessageFor(model => model.Login, "*", new { @class = "help-inline" }) </div> </div> <div class="control-group"> @Html.LabelFor(model => model.Password, new { @class = "control-label" }) <div class="controls"> @Html.PasswordFor(model => model.Password, new { @class= "input-large" }) @Html.ValidationMessageFor(model => model.Password, "*", new { @class = "help-inline" }) </div> </div> <div class="form-actions"> <input type="submit" class="btn btn-primary" value="Log On" /> </div> } }
Using your own HTML controls is an option, but you will need to do this in the same way as the helper methods above, otherwise the model will not be filled.
source share