MVC-Bootstrap forms styling-Problem
Ich habe da ein kleines Problem mit meinem bootstrap-mvc-form. die Marge für die form-Gruppe scheint nicht zu funktionieren, wenn ich mein Rasiermesser. Jegliche Hilfe würde sehr geschätzt werden.
Dies ist die form, nicht die styling richtig
@using (Html.BeginForm("Contact", "Home"))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="formGroupInputLarge1" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Name, new { @class = "form-control", placeholder = "Fullname", tabindex = 1 })
@Html.ValidationMessageFor(m => m.Name)
</div>
</div>
<div class="form-group">
<label for="formGroupInputLarge2" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control", placeholder = "Email Address", tabindex = 2 })
@Html.ValidationMessageFor(m => m.Email)
</div>
</div>
<div class="form-group">
<label for="formGroupInputLarge3" class="col-sm-2 control-label">Message</label>
<div class="col-sm-10">
@Html.TextAreaFor(m => m.Message, new { @class = "form-control", placeholder = "Message", tabindex = 3 })
@Html.ValidationMessageFor(m => m.Message)
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary btn-lg">Send Mail</button>
</div>
</div>
</form>
}
Aber sobald ich Beginnen, entfernen Sie die form braucht es das richtige styling
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="formGroupInputLarge1" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Name, new { @class = "form-control", placeholder = "Fullname", tabindex = 1 })
@Html.ValidationMessageFor(m => m.Name)
</div>
</div>
<div class="form-group">
<label for="formGroupInputLarge2" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control", placeholder = "Email Address", tabindex = 2 })
@Html.ValidationMessageFor(m => m.Email)
</div>
</div>
<div class="form-group">
<label for="formGroupInputLarge3" class="col-sm-2 control-label">Message</label>
<div class="col-sm-10">
@Html.TextAreaFor(m => m.Message, new { @class = "form-control", placeholder = "Message", tabindex = 3 })
@Html.ValidationMessageFor(m => m.Message)
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary btn-lg">Send Mail</button>
</div>
</div>
</form>
Sie öffnen das Formular-tag zweimal. Check-in element untersuchen in Ihrem browser und Sie werden sehen, es.
prüfen mit TwitterBootstrapMVC. Es könnte Ihr Leben leichter machen.
prüfen mit TwitterBootstrapMVC. Es könnte Ihr Leben leichter machen.
InformationsquelleAutor InitLipton | 2014-11-16
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ihre erstellen von verschachtelten Formulare (ein Formular innerhalb eines Formulars) ist ungültig und wird nicht unterstützt. Ändern
zu
entfernen und die zweite form-element (und das schließende tag)
Als seitliche Anmerkung, die
<label for="formGroupInputLarge1" ...>
ist nicht die Erstellung einer korrektenlabel
element, da diefor
Attribut hat keine Beziehung zu allen anderen Elementen im Formular. Stattdessen@Html.LabelFor(m => m.Name, new { @class = "col-sm-2 control-label" })
was verbindet das label mit der textbox.InformationsquelleAutor
Entfernen, die zweite die form und Verwendung:
InformationsquelleAutor JOBG
InformationsquelleAutor avdesh goswami