10

浏览器在我的表单旁边显示“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" />
    }
4

2 回答 2

33

将您的代码更改为(添加@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" />
}
于 2012-08-08T08:53:19.783 回答
5

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

于 2012-08-08T08:54:00.517 回答