0

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?

asked Apr 15, 2014 at 20:27
2
  • Are you sure that the error doesn't lie within the layout-file? Commented Apr 15, 2014 at 20:34
  • No my other pages works fine even with Razor Commented Apr 15, 2014 at 20:39

1 Answer 1

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.

answered Apr 15, 2014 at 20:37

2 Comments

I have another page that have a form inside the using(Html.Form) and it works perfectly. That is the reason I don't understand why I am getting this error.
Didnt say it wouldnt work, just said it wasnt wizely;)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.