多表单提交
Posted 露西&哈特菲利亚
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多表单提交相关的知识,希望对你有一定的参考价值。
控制器代码:
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="加" name="btn1" onclick="form1.submit()" /> <input type="button" value="减" 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>
以上是关于多表单提交的主要内容,如果未能解决你的问题,请参考以下文章