是否可以将样式属性添加到Html.BeginForm?
类似的东西:
@using (Html.BeginForm("Action","Controller", FormMethod.Post, new {@class="myClass"}, new {@style="margin-right:100px margin-top:50px"}))
{
}
答案 0 :(得分:3)
试
@using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { style = "margin-right:100px; margin-top:50px", @class = "myClass" }))
{
}
答案 1 :(得分:2)
//Try this format
@using (Html.BeginForm("Action", "Controller", null,FormMethod.Post, new { @style = "your styles ",@class = "your classname"}))
{
}
答案 2 :(得分:1)
看这里:
我不是MVC专家,但根据附件链接您的代码应该是这样的:
@using (Html.BeginForm("Action","Controller", FormMethod.Post, new {@class="myClass"}, new {style="margin-right:100px margin-top:50px"}))
{
}
希望这会有所帮助。 :)
答案 3 :(得分:1)
@using (Html.BeginForm("Index", "Home", null, FormMethod.Post, new { style = "margin-right:100px;margin-top:50px;border:1px solid red;", @class = "thFormClass" }))
{
}

试试这个它会起作用。