简体   繁体   English

如何从外部调用表单的后操作

[英]How to call the post action of a form from outside it

Hi Guys. 嗨,大家好。 I have a form that will be submitted when a button on my toolbar is clicked. 当我单击工具栏上的按钮时,我将提交一个表单。 That button is outside the form. 该按钮在表单之外。 How do I achieve this, below is what I have tried so far. 我如何做到这一点,以下是到目前为止我已经尝试过的方法。 Thanks. 谢谢。

The Button 按钮

<li>
    <a id="frmsub" title="" data-placement="bottom" data-title="Save" onclick="$('#testfrm').submit()">
        <span class="glyphicon glyphicon-floppy-save"></span>
    </a>
</li>

My Form 我的表格

<div class="vx-ds-widget">
    <div class="container">
        @using (Html.BeginForm("EditCreateProfile", "Manage", FormMethod.Post, new { @id = "testfrm" }))

I have also tried this but not is working so far 我也试过了,但是到目前为止还没有用

$('#frmsub').click(function () {
    $('#testfrm').submit();
});

Try: 尝试:

<script type="text/javascript">
    $(function () {
        $('#frmsub').click(function () {
            $('#testfrm').submit();
            return false; // to prevent link navigation
        });
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM