ASP .NET MVC 3 - 如何提交一个ajax的形式嵌套在HTML表单中 [英] ASP .NET MVC 3 - How to submit an ajax form nested within an html form

查看:266
本文介绍了ASP .NET MVC 3 - 如何提交一个ajax的形式嵌套在HTML表单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP .NET MVC 3项目,并与我的创建视图中的一个个问题。

I have an ASP .NET MVC 3 project and a problem with one of my 'Create' views.

我已经级联,我与阿贾克斯的形式已经实现下拉领域。

I have cascading drop-down fields that I have implemented with ajax forms.

视图是粗略地说 - 是这样的:

The view is roughly speaking - like this:

@using (Html.BeginForm(...))
{
    @Html.MyDropDown1

    using (Ajax.BeginForm(...))
    {
        @Ajax.MyDropdown2
        <input type="submit" value="Select" />
    }

    using (Ajax.BeginForm(...))
    {
        @Ajax.MyDropdown3
        <input type="submit" value="Select" />
    }

    <!-- other form fields -->

    <input type="submit" value="Create" />
}

问题是,提交按钮,里面的AJAX形式实际上提交外HTML表单。

The problem is that the submit buttons inside the ajax forms actually submit the outer html form.

有没有什么办法可以指定我想提交表单的名字?

Is there any way to specify the name of the form I want to submit?

我想过把我上面的html表单我的ajax的形式,以便不会有任何嵌套 - 但我需要在我的HTML后下拉的选择项的值

I thought about putting my ajax forms above my html form so there would not be any nesting - but I need the values of the drop-down's selected items in my html post.

谢谢, 皮特

推荐答案

正如在你不能有嵌套形式的评论。删除所有使用(Ajax.BeginForm(...))位,并通过处理您的jQuery AJAX调用(或其他事物)。

As pointed out in comments you can't have nested forms. Remove all the using (Ajax.BeginForm(...)) bits, and handle your ajax calls through jQuery (or sth else).

这篇关于ASP .NET MVC 3 - 如何提交一个ajax的形式嵌套在HTML表单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆