首页 > 代码库 > 多表单提交

多表单提交

控制器代码:

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using Mvc1.Models;namespace Mvc1.Controllers{    public class HomeController : Controller    {public ActionResult Other1()        {            return View();        }        public ActionResult FFF(string one, string two)        {            int end = Convert.ToInt32(one) + Convert.ToInt32(two);            Session["end"] = end;            return RedirectToAction("Other1");        }        public ActionResult GGG(string one, string two)        {            int end = Convert.ToInt32(one) - Convert.ToInt32(two);            Session["end"] = end;            return RedirectToAction("Other1");        }    }}

界面代码:

@{    Layout = null;}<!DOCTYPE html><html><head>    <meta name="viewport" content="width=device-width" />    <title>Other1</title></head><body>    <div>        <form id="form1" name="form1" method="post" action="FFF">            <input type="text" name="one" />            <input type="text" name="two" />            <br />            <input type="button" value=http://www.mamicode.com/"" name="btn1" onclick="form1.submit()" />            <input type="button" value=http://www.mamicode.com/"" name="btn1" id="jian" />        </form>        @{            if (Session["end"] != null)            {            <span>@Session["end"].ToString()</span>                Session["end"] = null;            }        }    </div></body></html><script type="text/javascript">    document.getElementById(jian).onclick = function () {        document.getElementById(form1).action = "GGG";        form1.submit();    };</script>

 

多表单提交