I am trying to add razor to my HTML but now I am getting a Parser Error and do not understand why I get this error:
HTML:
@model ServingTeam.DAL.Members
@{
ViewBag.Title = "New Member";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm("AddMember", "Home", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { role = "form" }))
{
<div class="row">
<div class="col-md-2">
</div>
<div class="col-sm-6">
<h2>
New Member</h2>
<form class="form-horizontal" role="form" id="memberForm">
<div class="form-group">
<label for="inputName" class="col-sm-2 control-label" />
Name</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control", placeholder = "Name", type = "text", required = "required " })
</div>
</div>
<div class="form-group">
<label for="inputName" class="col-sm-2 control-label">
Surname</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Surname, new { @class = "form-control", placeholder = "Surname", type = "text", required = "required " })
</div>
</div>
<div class="form-group">
<label for="inputName" class="col-sm-2 control-label">
Cell</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Cell, new { @class = "form-control", placeholder = "Cell", type = "text" })
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">
Email</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control", placeholder = "Enter email address", type = "email", required = "required " })
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-info">
Submit</button>
</div>
</div>
</form>
</div>
<div class="col-md-4">
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
<script>
$("#memberForm").validate();
</script>
This is the error I get: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? All works fine when I remove Razor.
Any help please?
-
Are you sure that the error doesn't lie within the layout-file?thsorens– thsorens2014年04月15日 20:34:50 +00:00Commented Apr 15, 2014 at 20:34
-
No my other pages works fine even with RazorGericke– Gericke2014年04月15日 20:39:19 +00:00Commented Apr 15, 2014 at 20:39
1 Answer 1
I did find one error in your markup, don't know if it has anything to do with your current error though.
<form class="form-horizontal" role="form" id="memberForm">
</form>
the using(Html.BeginForm) will actually create a form for you, now you have a form within the form, which is not wizely
<label for="inputName" class="col-sm-2 control-label" />
Name</label>
There you go. the label gets cancelled out twice.