I'm converting an Umbraco 8 site which used to have this code which worked by default:
<label class="text-input" for="staffName">
Search by staff name
@Html.TextBoxFor(a => a.staffName, new { placeholder = "Search for a person e.g. John Smith" })
</label>
<label class="select-input" for="SelectedSpecialism">
Filter by specialism
@Html.DropDownListFor(a => a.SelectedSpecialism, Model.specialismsDropdown)
</label>
<label class="select-input" for="SelectedOffice">
Filter by office
@Html.DropDownListFor(a => a.SelectedOffice, Model.officesDropdown)
</label>
<input type="submit" value="Search" class="btn" />
But in my new code this is throwing an error about dynamic items and can't see the model for some reason.
The error is "An expression tree cannot contain a dynamic operation"
Any help is much appreciated, I've worked out most other little bugs but this one is beyond me.
Model.specialismsDropdown - should contain the dropdown options - but that lowercase letter at the start - makes me think it might be somehow 'dynamic' ??
What is in the @Model or @inherits statement at the top of the view?
and can you post what that class looks like?
The dropdown options passed into DropDownListFor helper needs to be of type List<SelectedListItem>
using Microsoft.AspNetCore.Mvc.Rendering;
using Galbraithv13v2.Extensions;
namespace Umbraco.Cms.Web.Common.PublishedModels
{
public partial class StaffListing
{
public List<StaffProfile> StaffProfiles;
public int totalPages; //Total pages that will be made from query result
public PaginationData paginationData;
public string SelectedSpecialism;
public string SelectedOffice;
public string staffName;
public List<SelectListItem> specialismsDropdown;
public List<SelectListItem> officesDropdown;
}
}
As I mentioned above this worked fine in v8 but I can't seem to think of a solution for the v13 site. (Might be a lack of experience rather than something complex)
TextBoxfor not working with Umbraco 13 models?
Hi,
I'm converting an Umbraco 8 site which used to have this code which worked by default:
But in my new code this is throwing an error about dynamic items and can't see the model for some reason. The error is "An expression tree cannot contain a dynamic operation"
Any help is much appreciated, I've worked out most other little bugs but this one is beyond me.
Hi SandyK-W
What is the underlying class for your Model?
Model.specialismsDropdown - should contain the dropdown options - but that lowercase letter at the start - makes me think it might be somehow 'dynamic' ??
What is in the @Model or @inherits statement at the top of the view?
and can you post what that class looks like?
The dropdown options passed into DropDownListFor helper needs to be of type
List<SelectedListItem>
regards
marc
regards
Marc
Hi Mark,
Thanks for replying!
My using/inherits statements:
and here is the extended model class:
As I mentioned above this worked fine in v8 but I can't seem to think of a solution for the v13 site. (Might be a lack of experience rather than something complex)
Thanks, Sandy
is working on a reply...