我已经阅读了多篇关于类似问题的帖子,但没有奏效。
我修复了页脚按钮,并且在 Project Controller 中调用“发布”版本 Edit 操作时遇到问题。这是我正在尝试做的事情
如果问题需要进一步解释,请告诉我。
(我尝试使用 Ajax.ActionLink,这也在多个帖子中被推荐但没有成功。
最佳答案
最后我设法通过一些变通办法修复了它。在此处发布解决方案以帮助某人。
正如我之前所说,我尝试使用 Ajax.ActionLink 但我无法实现同样的效果。相反,我寻找的是从表单外部调用表单提交操作,这正是我在这里真正需要的。
表单:为您的表单命名,比如“editProjDetailsForm”
@using (Html.BeginForm(null, null, FormMethod.Post,<br/>
new { @class = "form-horizontal",<br/>
name = "editProjDetailsForm" }))
页脚从页脚按钮调用此方法。
<input type="button" onclick="document.editProjDetailsForm.submit();"
class="btn btn-primary"
value="Save Changes" />
我也在页脚中尝试了这个,但没有成功:
@Ajax.ActionLink("Save Changes", "Edit", new { id = Model.ProjectId },
new AjaxOptions { HttpMethod = "POST" })
有用的帖子
- Naming A form using Begin Form
- Submit Button outside HTML.BeginForm
- Submit Button outside HTML.BeginForm (another link)
- ASP.net ActionLink and POST Method
- Error in case you have parameterized constructor in ViewModel and did not declare parameterless constructor
如果您使用 bootstrap,则显示问题 在页脚中,我有一个输入类型 = 按钮和一个带有类 = 按钮的操作链接。两者都嵌套在一个 btn 组中,但在以下快照中可见高度不同:
修复:发现这是一个已知问题,并且有一个建议的解决方案,但对我来说效果不佳(即对于 Internet Explorer)。 input type=submit and anchor button in btn-group appear as different sizes
解决方法:添加.btn { line-height:normal!important; }
或者,如果您只想对特定按钮执行操作,请说上面的输入按钮,然后执行以下操作:
<input type="button" onclick="document.editProjDetailsForm.submit();"
class="btn btn-primary"
value="Save Changes"
style="line-height:normal!important;" />
关于asp.net-mvc-4 - 使用 HTML.ActionLink 调用 Post 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17371708/