KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an entity called Domain.Models.BlogPost which contains the following properties: PostID Title Author PostedDate Body I also have an entity called Domain.Models.PostComment which contains the following properties: CommentID PostID Author Email Website Body BlogPost contains many PostComments . A one to many relationship. Now I have a view like this (separated comment form from blog post code via html comment): @model Domain.Models.BlogPost @using Domain.Models; @{ ViewBag.Title = "Post"; } <div class="postTitle">@Model.Title</div> <div class="subInfo"> Posted by @Model.Author on @Model.PostedDate.ToString("D") </div> <div class="postBody"> @Html.Markdown(Model.Body) </div> <br /> @Model.PostComments.Count Comment(s). <div class="comments"> @foreach (PostComment postComment in Model.PostComments) { Html.RenderPartial("PostComment", postComment); } </div> <!-- BELOW IS THE ADD COMMENT FORM --> <div id="addComment"> @using (Html.BeginForm("AddComment", "Blog")) { <text> @Html.Hidden("PostID", Model.PostID)<br /> Name: @Html.TextBox("Author")<br /> Email: @Html.TextBox("Email")<br /> Website: @Html.TextBox("Website")<br /> Body: @Html.TextArea("Body")<br /> <input type="submit" value = "Add Comment" /> </text> } </div> @Html.ActionLink("Add Comment", "AddComment") The problem is that because the comment form uses @Html.TextBox("Author") and @Html.TextBox("Body") , they are populated with data from the model, which also contains properties Author and Body . Any suggestions on how to fix this so these fields don't get v
Tags (comma-separated)
Save Edits
Cancel