<div class="forms-box">
<div class="inputs">
@Html.HiddenFor(model => model.AddNewComment.CommentParentID)
@Html.LabelFor(model => model.AddNewComment.CommentText)
<div class="input-box">
@Html.TextAreaFor(
model => model.AddNewComment.CommentText,
new { @class = "comment-text" })
</div>
@Html.ValidationMessageFor(model => model.AddNewComment.CommentText)
</div>
在代码中:
我从两个
获得一个值Model.AddNewComment.CommentParentID或
Model.AddNewComment.CommentText
在我的控制器中。
public ActionResult BlogCommentReply(
int blogPostId,
BlogPostModel model,
bool captchaValid)
{
}
答案 0 :(得分:0)
解决方案: model.AddNewComment.CommentText字段是强制性的。 所以我只是做了以下事情。
@using (Html.BeginForm())
{
<div id="div_@Count" style="display: none;">
@{CommentParentID = comment.Id;
Model.AddNewComment.CommentParentID = CommentParentID;
Model.AddNewComment.CommentText = comment.CommentText;}
<div id="ChildComments">
@Html.HiddenFor(model => model.AddNewComment.CommentParentID)
@Html.Label("Reply Comment")
<div>
@Html.TextAreaFor(model => model.AddNewComment.ChildCommentText)
</div>
@Html.HiddenFor(model => model.AddNewComment.CommentText)
</div>
<div class="buttons">
<input type="submit" name="reply-comment" value="@T("Blog.Comments.ReplyButton")" />
</div>
</div>
}