2013-01-07 10 views
-1

blogpost 중첩 된 의견을 작업하고 있습니다.단일보기 면도기에서 하나 이상의 html.begin을 사용할 수 있습니까?

저는 html.beginform에 익숙합니다. 하나는 새로운 의견을 추가하고 다른 하나는 답장입니다.

내보기 :

 <fieldset class="new-comment"> 
      <legend class="title">@T("Blog.Comments.LeaveYourComment")</legend> 
      @using (Html.BeginForm()) 
      { 
       <div id="newcomment"> 
        <div class="message-error">@Html.ValidationSummary(true)</div> 
        @{ 
       string result = TempData["nop.blog.addcomment.result"] as string; 
        } 
        @if (!String.IsNullOrEmpty(result)) 
        { 
         <div class="result">@result</div> 
        } 
        <div class="forms-box"> 
         <div class="inputs"> 
          @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> 
         @if (Model.AddNewComment.DisplayCaptcha) 
         { 
          <div class="captcha-box"> 
           @Html.Raw(Html.GenerateCaptcha()) 
          </div> 
          <div class="clear"> 
          </div> 
         } 
        </div> 
        <div class="clear"> 
        </div> 
        <div class="buttons"> 
         <input type="submit" name="add-comment" class="button-1 blog-post-add-comment-button" value="@T("Blog.Comments.SubmitButton")" /> 
        </div> 
       </div> 


      } 
     </fieldset> 

회신 : 내가 답장 버튼을 클릭하면

 <div class="container"> 

       @{//to set div id in comment list 
      var Count = 0; 
      var CommentParentID = 0;  } 
       @using (Html.BeginForm()) 
       { 


        foreach (var commentlist in Model.Comments.Where(x => x.CommentParentID == 0)) 
        { 

        <div class="nested-comments"> 



         <div> 
          @if (commentlist.AllowViewingProfiles) 
          { 
           <a href="@Url.RouteUrl("CustomerProfile", new { id = commentlist.CustomerId })" class="username">@(commentlist.CustomerName)</a> 
          } 
          else 
          { 
           <span class="username">@(commentlist.CustomerName)</span> 
          } 
          <div class="avatar"> 
           @if (!String.IsNullOrEmpty(commentlist.CustomerAvatarUrl)) 
           { 
            <img src="@(commentlist.CustomerAvatarUrl)" class="avatar-img" title="avatar" alt="avatar" /> 
           } 
          </div> 


          <div class="comment-content"> 
           <div class="comment-time"> 
            @T("Blog.Comments.CreatedOn"): <span class="stat-value">@commentlist.CreatedOn.ToString("g")</span> 

             <div> 
              <div id="[email protected]" style="display: none;"> 
               @{CommentParentID = commentlist.Id; 
                Model.AddNewComment.CommentParentID = CommentParentID;} 

               <div> 

                <div class="message-error">@Html.ValidationSummary(true)</div> 
               @{ 
               string strresult = TempData["nop.blog.addcomment.result"] as string;         
               } 
               @if (!String.IsNullOrEmpty(strresult)) 
               { 
                <div class="result">@strresult</div> 
               } 
                <div> 
                 <div id="[email protected]"> 
                  @Html.HiddenFor(modelComment => modelComment.AddNewComment.CommentParentID) 
                  @Html.Label("Reply Comment") 
                  <div> 
                   @Html.TextAreaFor(modelComment => modelComment.AddNewComment.ChildCommentText) 
                  </div> 
                  @Html.ValidationMessageFor(modelComment => modelComment.AddNewComment.ChildCommentText,"Please Enter Reply") 
                 </div> 

                 @if (Model.AddNewComment.DisplayCaptcha) 
                 { 
                  <div class="captcha-box"> 
                   @Html.Raw(Html.GenerateCaptcha()) 
                  </div> 
                  <div class="clear"> 
                  </div> 
                 } 
                </div> 
                <div class="clear"> 
                </div> 
                <div class="buttons"> 
                 <input type="submit" name="reply-comment" value="@T("Blog.Comments.ReplyButton")" /> 
                </div> 
               </div> 
               <div class="clear"> 
               </div> 



              </div> 

              <input type="button" id="reply" class="reply-link" onclick="return showHide('[email protected]');" value="Reply" /> 
              @{Count++; } 
             </div> 

           </div> 
           <div class="comment-body"> 
            @Html.Raw(Nop.Core.Html.HtmlHelper.FormatText(commentlist.CommentText, false, true, false, false, false, false)) 
           </div> 
          </div> 


          <div class="clear"> 
          </div> 


          @foreach (var cmt in Model.Comments.Where(x => x.CommentParentID == commentlist.Id)) 
          { 
           <div class="comment"> 
            <div> 
             <div class="user-info"> 
              @if (cmt.AllowViewingProfiles) 
              { 
               <a href="@Url.RouteUrl("CustomerProfile", new { id = cmt.CustomerId })" class="username">@(cmt.CustomerName)</a> 
              } 
              else 
              { 
               <span class="username">@(cmt.CustomerName)</span> 
              } 
              <div class="avatar"> 
               @if (!String.IsNullOrEmpty(cmt.CustomerAvatarUrl)) 
               { 
                <img src="@(cmt.CustomerAvatarUrl)" class="avatar-img" title="avatar" alt="avatar" /> 
               } 
              </div> 
             </div> 
            </div> 
            <div class="comment-content"> 
             <div class="comment-time"> 
              @T("Blog.Comments.CreatedOn"): <span class="stat-value">@cmt.CreatedOn.ToString("g")</span> 
             </div> 
             <div class="comment-body"> 
              @Html.Raw(Nop.Core.Html.HtmlHelper.FormatText(cmt.CommentText, false, true, false, false, false, false)) 
             </div> 
            </div> 

           </div> 
          } 
          @Html.Widget("blogpost_page_inside_comment") 

         </div> 
        </div> 

        } 

       } 

      </div> 

내가 modelComment => modelComment.AddNewComment.ChildCommentText

+1

여러 개의 html.beginform()을 사용할 수 있습니다.

태그 만 생성 중입니다. 물론 중첩 된 양식 태그를 사용할 수는 없습니다. – Anonymous

+0

@Anonymous : 위 코드가 맞습니까? –

+0

@NetraWable에서 오류를 볼 수 있습니까 –

답변

0
에 대한 매개 변수 값을 얻을 수 아니다

예 하나의 페이지가 다른 페이지의 안에 중첩되어 있지 않은 한, 한 페이지에 둘 이상의 양식을 포함 할 수 있습니다.

디버깅하면 어떻게됩니까? 올바른 동작으로 이동하고 값을 전달하지 않습니까?

+0

: 그것은 올바른 조치로 이동합니다 나는 어떤 오류도 얻지 못했지만 회신의 제출에 expection 오전 값은 null입니다. –

관련 문제