Kira
Kira

Reputation: 1207

got "System.Web.Mvc.Html.MvcForm" on page

The browser is displaying "System.Web.Mvc.Html.MvcForm" next to my form. How can I hide it? Here is the form code.

 @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" />
    }

Upvotes: 10

Views: 8026

Answers (2)

Prafulla
Prafulla

Reputation: 1939

Change the line @Html.BeginForm("NewComment", "Difficultes", FormMethod.Post) to @using(Html.BeginForm("NewComment", "Difficultes", FormMethod.Post))

Upvotes: 5

Hadas
Hadas

Reputation: 10374

Change your code to (Add the @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" />
}

Upvotes: 33

Related Questions