Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I created a macro called pSearch, which contains the following code:
pSearch
@inherits Umbraco.Web.Macros.PartialViewMacroPage @using DS.Models @model ProductFilterModel @using (@Html.BeginUmbracoForm("Search", "ProductSearch", new { @Model }, new { @class = "vehicle-filter group", @id = "productFilterForm" }, FormMethod.Get)) { <div class="select"> <select id="YearDropDownList" name="VehicleYear" class="year" data-request-url="@Url.Action("GetVehicleYears","ProductFilter")"> </select> </div> <div class="select"> <select id="MakeDropDownList" name="VehicleMakeId" class="make" disabled data-request-url="@Url.Action("GetVehicleMakes","ProductFilter")"></select> @Html.HiddenFor(x => x.VehicleMake) </div> <div class="select"> <select id="ModelDropDownList" name="VehicleModelId" class="model" disabled data-request-url="@Url.Action("GetVehicleModels","ProductFilter")"></select> @Html.HiddenFor(x => x.VehicleModel) </div> <div class="select"> <select id="EngineDropDownList" name="VehicleEngineId" class="engine" disabled data-request-url="@Url.Action("GetVehicleEngines","ProductFilter")"></select> @Html.HiddenFor(x => x.VehicleEngine) </div> <button id="search" type="submit" class="search-button" disabled>SEARCH</button> }
Then in my search.cshtml file, I am calling this:
@Umbraco.RenderMacro("pSearch",new ProductFilterModel())
But when I got to my search page, it says:
Error loading Partial View script (file: ~/Views/MacroPartials/psearch.cshtml)
Apparently, it has something to do with the @inherits keyword is not allowed within @model, so what is the best way to handle this if I need to inherit and pass a custom object model?
@inherits keyword is not allowed within @model
I ended up removing the @model and doing something like this:
@model
@using (@Html.BeginUmbracoForm("Search", "ProductSearch", new ProductFilterModel(), new { @class = "vehicle-filter group", @id = "productFilterForm" }, FormMethod.Get)) {....
This seems to work, but I am not sure if it is the right way
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Is it possible to pass a custom object into @Umbraco.RenderMacro?
I created a macro called
pSearch
, which contains the following code:Then in my search.cshtml file, I am calling this:
@Umbraco.RenderMacro("pSearch",new ProductFilterModel())
But when I got to my search page, it says:
Error loading Partial View script (file: ~/Views/MacroPartials/psearch.cshtml)
Apparently, it has something to do with the
@inherits keyword is not allowed within @model
, so what is the best way to handle this if I need to inherit and pass a custom object model?I ended up removing the
@model
and doing something like this:@using (@Html.BeginUmbracoForm("Search", "ProductSearch", new ProductFilterModel(), new { @class = "vehicle-filter group", @id = "productFilterForm" }, FormMethod.Get)) {....
This seems to work, but I am not sure if it is the right way
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.