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>

コード内:

2つの値からいずれか1つの値を取得します

  1. Model.AddNewComment.CommentParentID または

  2. Model.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 に答える