This is my control
/ProductController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShoppingStore.Domain.Abstract;
using ShoppingStore.Domain.Entities;
using ShoppingStore.WebUI.Models;
namespace ShoppingStore.WebUI.Controllers
{
public class ProductController : Controller
{
private IProductsRepository repository;
public int PageSize = 4;
public ProductController(IProductsRepository productRepository)
{
this.repository = productRepository;
}
public ViewResult List(string category , int page=1)
{
ProductsListViewModel model = new ProductsListViewModel
{
// Products = repository.Products.OrderBy(p => p.ProductID).Skip((page - 1) * PageSize).Take(PageSize),
Products = repository.Products.Where(p => category ==null || p.Category ==category).OrderBy(p => p.ProductID).Skip((page - 1) * PageSize).Take(PageSize),
PageInfo = new PagingInfo {CurentPage = page,ItemPerPage = PageSize,TotalItems = category == null ? repository.Products.Count() : repository.Products.Where(e => e.Category == category).Count()},
CurrentCategory = category
};
return View(model);
}
[HttpPost]
public ActionResult Save(List<string> hiddenList)
{
return View();
}
}
}
This is View
/Views/Product/List.cshtml
@model ShoppingStore.WebUI.Models.ProductsListViewModel
@{
ViewBag.Title = "Prodcuts";
}
<script src="~/Scripts/pop_window.js"></script>
<script src="~/Scripts/tool.js"></script>
@foreach (var p in Model.Products)
{
@Html.Partial("ProductSummary",p)
}
<div>
@Html.PageLinks(Model.PageInfo, x => Url.Action("List", new { page = x , category = Model.CurrentCategory}))
</div>
<div>
<div id="result" style="display:none;"></div>
@using (Html.BeginForm("Save", "Product", FormMethod.Post))
{
<div id="dialog" title="Basic dialog">
<ol id="test"></ol>
<div id="detail">
<div>
<input class="ice-checkbox" type="checkbox" name="driink_d" id="BigICE" value="BigICE">cold/big/L $8<br>
<input class="ice-checkbox" type="checkbox" name="driink_d" id="MidHOT" value="MidHOT">hot/mid/M $7<br>
<input class="ice-checkbox" type="checkbox" name="driink_d" id="BigHOT" value="BigHOT">hot/big/L $7<br>
</div>
<div>
<input class="size-checkbox" type="checkbox" name="driink_d" id="NOICE" value="NOICE">no ice<br>
<input class="size-checkbox" type="checkbox" name="driink_d" id="NORL" value="NORL">normal<br>
<input class="size-checkbox" type="checkbox" name="driink_d" id="LESSICE" value="LESSICE">less ice<br>
</div>
<div>
<input class="sugar-checkbox" type="checkbox" name="driink_d" id="LESS" value="LESS">Less<br>
<input class="sugar-checkbox" type="checkbox" name="driink_d" id="HALF" value="HALF">half<br>
<input class="sugar-checkbox" type="checkbox" name="driink_d" id="FULL" value="FULL">full<br>
<input class="sugar-checkbox" type="checkbox" name="driink_d" id="NOS" value="NOS">no<br>
</div>
</div>
<div>
<div id='DIV2'><input type="button" onclick="incrementValue1()" value="ADD" /></div>
<div id="DIV2"> <input type="text" id="number1" value="0" /></div>
<div id="DIV2"><input type="button" onclick="decrementValue1()" value="minus" /></div>
</div>
<button id="checkvalue" onclick="checkValue()" type="submit">Check</button>
</div>
}
When my project starts running, List.cshtml work is fine .
It can read data from the database, and show information to browser.
But I have a form, want to send some values to ProductController.cs .
It can not work, even I put breakpoint in ProductController.cs .
use Html.BeginForm("Save", "Product", FormMethod.Post)
It can not find 'Save' action name in the ProductController.cs


[HttpPost]- but you have other errors and the value of yourhiddenListwill benull.