0
<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>

在代码中:

我从两个中得到一个值

  1. Model.AddNewComment.CommentParentID 或

  2. 模型.AddNewComment.CommentText

在我的控制器中。

  public ActionResult BlogCommentReply(
         int blogPostId,
         BlogPostModel model, 
         bool captchaValid)
 {

 }
4

1 回答 1

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>



                        }
于 2013-01-08T07:40:55.183 回答