I'm working on a project to learn ASP.NET MVC and Razor. I currently have a post
template with a view , and a view associated with the model class comment to create a new comment. I would like to know how to do to put the view comment creation at the end of the post , and when to submit the comment to the post as an associate (I have a% of the comment to make the association). I inserted manually some comments in the database and they appear in the right place because I put PostId
manually, which is not functional. See view to create a comment:
@model shanuMVCUserRoles.CommentSet
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>CommentSet</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MemberID, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MemberID, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MemberID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PostID, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.PostID, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.PostID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Content, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>