2013-06-28 212 views
3

我已经阅读了关于类似问题的多篇文章,但没有奏效。使用HTML.ActionLink调用Post方法

我已经在项目控制器叫“邮报”的版本编辑动作固定页脚按钮和面临的问题。这里是我想要做的

Error

让我知道如果问题需要进一步的解释。

(我尝试使用Ajax.ActionLink其建议在多个帖子太多,但没有成功。

Similar Question

回答

7

最后我设法通过一些解决方法来解决它。发帖这里的解决方案,以帮助别人。

就像我刚才所说,我尝试使用Ajax.ActionLink,但我没能达到相同的。相反,我找了调用形式从形式之外提交的动作,这就是我真正需要在这里。

形式:名称表单的东西,说 “editProjDetailsForm”
@using (Html.BeginForm(null, null, FormMethod.Post,
new { @class = "form-horizontal",
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" }) 

有用的帖子

  1. Naming A form using Begin Form
  2. Submit Button outside HTML.BeginForm
  3. Submit Button outside HTML.BeginForm (another link)
  4. ASP.net ActionLink and POST Method
  5. Error in case you have parameterized constructor in ViewModel and did not declare parameterless constructor

显示问题,如果你使用的是引导在页脚我有一个输入类型=按钮,带class =按钮,一个动作链接。这两个嵌套在一个BTN-组,但有高度是在以下快照表现为明显的不同:

Different buttons

修复:发现,这是一个已知的问题,有一个建议的解决方案,但没有奏效(对于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;" /> 
+0

虽然不完全是一个问题,我有相关的,我做了gleem这篇文章提供了一些有用的信息,非常感谢! – JonE