微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net-mvc-4 – 使用HTML.ActionLink调用Post方法

我已经阅读了类似问题的多篇帖子,但没有奏效.

我有一个固定的页脚按钮,并在调用项目控制器中的“发布”版本编辑操作时面临问题.这就是我想要做

 

如果问题需要进一步解释,请告诉我.

(我尝试使用Ajax.ActionLink,这也是在多个帖子中提出的,但没有成功.

Similar Question

解决方法

最后,我设法通过一些解决方法来修复它.在这里发布解决方案以帮助某人.

就像我之前说的那样,我尝试使用Ajax.ActionLink,但我无法实现相同的目标.相反,我从表格之外寻找呼叫表单提交操作,这是我在这里真正需要的.

表单:为表单命名,说“editProjDetailsForm”
 @using(Html.BeginForm(null,null,FormMethod.Post,
                        新{@class =“形式水平”,
    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显示问题在页脚中我有一个输入类型=按钮和一个带有class =按钮的操作链接.两者都嵌套在一个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;" />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐