0

我正在开发 ASP MVC 4 Web 应用程序,用户可以在其中按特定功能过滤项目。我在我的视图中使用表单但是表单提交 null 被传递给控制器

这是代码片段

看法:

 @using (Html.BeginForm("Category", "Catalog", new {filteringModel = Model.ProductFilteringModel}))
        {
        <div>
            <div class="filter-item">
                <h1 id="filter-parameters">
                    по  параметрам
                    <br/>
                </h1>
                <div class="filter-field-input">
                    @Html.CheckBoxFor(x => x.ProductFilteringModel.ShowAvailable)    
                </div>
                <div class="filter-field-title">
                    @Html.LabelFor(x => x.ProductFilteringModel.ShowAvailable)
                </div>
            </div>
            <div class="filter-item">
                <ul class="filter-field-list">
                @foreach (var skinType in Model.ProductFilteringModel.SkinTypes)
                {
                    <li class="filter-list-item">
                        <div class="filter-field-input">
                            @Html.CheckBox(skinType.Title, false)
                        </div>
                        <div class="filter-field-title">
                            @Html.Label(skinType.Title)
                        </div>
                    </li>
                }
                </ul>
            </div>
            <div class="filter-item">
                <ul class="filter-field-list">
                    @foreach (var expected in Model.ProductFilteringModel.ExpectedResults)
                    {
                        <li class="filter-list-item">
                            <div class="filter-field-input">
                                @Html.CheckBox(expected.Title, false)
                            </div>
                            <div class="filter-field-title">
                                @Html.Label(expected.Title)
                            </div>
                        </li>
                    }
                </ul>
             </div>
            <input type="submit" value="Filter"/>
        </div>
        }

控制器:

       public ActionResult Category(int categoryId, CatalogPagingFilteringModel command, ProductFilteringModel filteringModel)
    {
     //Do something
    }

还有我的过滤模型:

    public class ProductFilteringModel
{
    public bool ShowAvailable { get; set; }
    public List<ItemFeatureModel> SkinTypes { get; set; }
    public List<ItemFeatureModel> ExpectedResults { get; set; }
}

public class ItemFeatureModel
{
    public string Id { get; set; }
    public string Title { get; set; }
    public bool Selected { get; set; }
}
4

0 回答 0