Asp.net

在頁面上得到“System.Web.Mvc.Html.MvcForm”

  • December 31, 2016

瀏覽器在我的表單旁邊顯示“System.Web.Mvc.Html.MvcForm”。我該如何隱藏它?這是表單程式碼。

@Html.BeginForm("NewComment", "Difficultes", FormMethod.Post)
   {        
   @Html.HiddenFor(m => m.diff.id_diff) 
       <table>
           <tr><label><b>Nouveau commentaire</b></label></tr>
           <tr>
           <td><b>Nom :</b></td><td>@Html.TextBoxFor(m=>m.pseudo)</td>
           </tr>
           <tr>
           <td><b>Commentaire :</b></td><td>@Html.TextAreaFor(m=>m.nouveau)</td>
           </tr>
       </table>

       <input type="submit" value="Ajouter" />
   }

將您的程式碼更改為(添加@using):

@using (Html.BeginForm("NewComment", "Difficultes", FormMethod.Post))
{        
   @Html.HiddenFor(m => m.diff.id_diff) 
   <table>
       <tr><label><b>Nouveau commentaire</b></label></tr>
       <tr>
       <td><b>Nom :</b></td><td>@Html.TextBoxFor(m=>m.pseudo)</td>
       </tr>
       <tr>
       <td><b>Commentaire :</b></td><td>@Html.TextAreaFor(m=>m.nouveau)</td>
       </tr>
   </table>

   <input type="submit" value="Ajouter" />
}

將行更改@Html.BeginForm("NewComment", "Difficultes", FormMethod.Post)@using(Html.BeginForm("NewComment", "Difficultes", FormMethod.Post))

引用自:https://stackoverflow.com/questions/11860902