87

次の状況でクラス属性を追加する方法 (ReturnUrl のみを使用):

@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))
{
}

私はこのようなものが欲しい:

@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }, new { @class = "login-form" })) 
{
}
4

3 に答える 3

165

コントローラーのアクション、名前、およびフォーム メソッドを指定すると、そのためのオーバーロードがあります。

@using (Html.BeginForm("ActionName", "ControllerName", 
            new { ReturnUrl = ViewBag.ReturnUrl }, 
            FormMethod.Post, new { @class="login-form" }))
{
  etc.
}
于 2012-12-21T03:59:22.370 に答える
1
Html.BeginForm("Index", "EIApplication", FormMethod.Post, new { enctype = "multipart/form-data", **@class = "nea-forms"** })
于 2019-07-02T09:08:31.507 に答える