我有Html.BeginForm
的编辑操作。如何添加HTML属性?
我只知道一种方法:
@using (Html.BeginForm("Edit", "Clients", FormMethod.Post, new { @class="example"})) {
}
但是如果我使用这个方法,我不能传递当前ID
是否可以在不修改操作URL的情况下向表单添加HTML属性?
发布于 2018-03-04 04:49:45
Action和Controller参数也可以为空以使用默认操作:
Html.BeginForm( null, null, FormMethod.Post, new { id=”formname”, @class="formclass" })
发布于 2012-12-22 13:56:21
从ControllerA通过ActionLink调用
@using (Html.BeginForm("Create",
"StudentPChoice",
new { StudentPChoiceId = Model.StudentPChoiceId },
FormMethod.Post))
{
}
或
@using (Html.BeginForm("Create",
"ControllerB",
new { ControllerBId = Model.ControllerAId },
FormMethod.Post))
{
}
发布于 2019-02-11 01:33:23
如果这对某些人有帮助,那么我也可以这么做:
@using (Html.BeginForm("RefreshData", "Home", FormMethod.Post,
new { Id = "timerangeId", @name = "timerange" }))
{
// form elements and input
}
在Javascript中:
document.getElementById("timerangeId").submit();
https://stackoverflow.com/questions/10972558
复制相似问题