asp.net - MVC 在 MVC Html.BeginForm() 中添加 id 和 css 类

标签 asp.net asp.net-mvc asp.net-mvc-4

我是 MVC 的新手。

如何在 MVC Html.BeginForm() 中添加 id 和 css 类。

这是 html 表单。

<form id="frmId" class="frmStyle">
    ...
</form>

我试过这个,但有错误。
@Html.BeginForm("actionName", "controllerName", new {id="frmId", class = "frmStyle"})

最佳答案

我们添加为 htmlAttributes 的一部分。

@Html.BeginForm("actionName", "controllerName", FormMethod.Post,
 new {id="frmId", @class = "frmStyle"})

关于asp.net - MVC 在 MVC Html.BeginForm() 中添加 id 和 css 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23063162/

相关文章:

jquery - 如何在 mvc3 中将值列表发送到 Controller

asp.net - 检测 SQL 的非关闭连接

asp.net - json foursquare api 中的前缀

asp.net-mvc - 如何从命令行重新启动 mod-mono asp.net 应用程序?

c#-4.0 - 如何在 MVC4 中使用带有 Html 文本框助手的按键按下事件

c# - foreach 中的删除线文本?

c# - Post 方法在 ASP.NET Core 中不起作用

asp.net - 在 ASP.NET 页面中播放视频

asp.net-mvc 功能 - 每个( View /母版页/用户控件)一个 css 文件

javascript - Ajax 模态仅工作一次