发布表单并重定向到操作ASP.NET MVC

ddd*_*ddd 6 asp.net-mvc

我有一个导航栏,使用JQuery在注册过程的4个阶段之间移动.

但是,我需要确保所有内容都与JS禁用.

所以我在页面底部有这4个链接图像,我需要这样,如果单击它,它会发布到当前操作,这样我就可以保存所有表单数据,然后重定向到下一个阶段.

重定向很简单,因为我只是在路由或表单中传递参数,但我不知道如何使用动作链接发布方法.

我可以为图像背景等放置4个不同的提交按钮,但这感觉不对.

有任何想法吗?

Dar*_*rov 2

您的表单上可以有多个提交按钮:

<input type="submit" name="step1" value="Step 1"/>
<input type="submit" name="step2" value="Step 2"/>
<input type="submit" name="step3" value="Step 3"/>
Run Code Online (Sandbox Code Playgroud)

并在你的行动中:

public ActionResult Action(FormCollection form)
{
    if (!string.IsNullOrEmpty(form["step1"]))
    {
        // Step 1 button was clicked
    } 
    else if (!string.IsNullOrEmpty(form["step2"]))
    {
        // Step 2 button was clicked
    }
    else if (!string.IsNullOrEmpty(form["step3"]))
    {
        // Step 3 button was clicked
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)