[HttpGet] public ActionResult Index() { return View(_bag.GetBag); } [HttpPost] public ActionResult Index(string method ="None" ) { switch (method) { case "Add10": _bag.GetBag = Get100Products().Take(10).ToList<Product>(); break; case "Clear": _bag = null; _bag = new Models.Bag(); break; case "Add": if ((Request.Form["Id"] != null) && (Request.Form["Id"] != "")) { if (_bag.GetBag.Count < 100) { var p = GetProduct(Request.Form["Id"]); int qnt = Convert.ToInt16(Request.Form["qnt"]); if (p.ItemNumber != null) { p.Quantity = qnt; p.Index++; _bag.Item = p; } } } break; } return View(_bag.GetBag); }
<div style="vertical-align:middle"> @using (Html.BeginForm("", "Home", new { method = "Add10" }, FormMethod.Post)) { <!-- form goes here --> <input type="submit" value="Add 10 Items to bag" /> } @using (Html.BeginForm("GetDiscount", "Home", FormMethod.Post)) { <div> <!-- form goes here --> <input type="submit" value="Get Discount" /> With MAX time in seconds <input type="text" name="time" maxlength="2" value="2" /> </div> } @using (Html.BeginForm("", "Home", new { method = "Clear" }, FormMethod.Post)) { <input type="submit" value="Empty the bag" /> } </div></form>
[HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken]
<input type="button" command="Clear"/>
if(command=="Add10") { //Your Logoc }
if(command=="Add10") { //Your Logic }
[HttpPost] public ActionResult Index(string method ="None" ) {
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)