I have a Partial View that has the contains this snippet of BeginUmbracoForm:
@model ProductFilterModel
@using (@Html.BeginForm("Search", "ProductSearch", new {model = new ProductFilterModel(),@Model.YearId, @Model.MakeId, @Model.ModelId, Engine = @Model.EngineId }, FormMethod.Get, new { @class = "vehicle-filter group", @id = "productFilterForm" }))
{...
When the Search Action is called, the model object is null, but the other values are fine. I was trying to just pass model = new ProductFilter(MakeId = @Model.MakeId....), but it is null when it hits the Action. Here is the Action method:
//model is null, but the other string values are not
public ActionResult Search(ProductFilterModel model, string yearId, string makeId, string modelId, string engineId)
{
var db = new Database("productsDb");
var productSearchResultsModel = new ProductSearchResultsModel
{
ProductFilterModel = new ProductFilterModel{ YearId = yearId, MakeId = makeId, ModelId = modelId, EngineId = engineId},
Products = db.Fetch<ProductViewModel>(@"SELECT DISTINCT(p.ProductID) As ProductId, Type, Name, PartNumber, ShortDescription
FROM Products p
INNER JOIN productlink pl on pl.ProductID = p.ProductID
INNER JOIN vehicles v on v.VehicleID = pl.VehicleID
WHERE Brand = 'SCT'
AND v.Make = @MakeId
AND v.Model = @ModelId
AND v.Engine = @EngineId
AND v.Year = @YearId", new { YearId = yearId,MakeId = makeId,ModelId = modelId,EngineId = engineId })
};
return View("~/Views/Filter.cshtml",productSearchResultsModel);
}
Passing model to BeginUmbracoForm Action is null?
I have a Partial View that has the contains this snippet of
BeginUmbracoForm
:When the Search Action is called, the model object is null, but the other values are fine. I was trying to just pass
model = new ProductFilter(MakeId = @Model.MakeId....)
, but it is null when it hits the Action. Here is the Action method:For a start your snippet uses
BeginForm
instead ofBeginUmbracoForm
is working on a reply...