Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • SandyK-W 24 posts 64 karma points
    6 days ago
    SandyK-W
    0

    IHtmlHelper not accepting model?

    Here is the top part of the code:

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.PropertyListing>;
    @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
    @using System.Linq;
    @using System.Linq.Expressions;
    @using System.Web;
    @using System.Collections.Specialized;
    @using Galbraithv13v2.Services.PropertySearch.Models;
    @using Galbraithv13v2.Services;
    @using Galbraithv13v2.Extensions;
    @inject ISiteService SiteService;
    @inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
    
    @{
        IPublishedContent globalContent = SiteService.GetSettingsNode();
        var globalSettings = globalContent.FirstChild<Settings>();
        var primaryFilterSize = Model.sq.Channel == PropertyChannel.ForestryAndWoodland ? "sm" : null;
        var Request = HttpContextAccessor.HttpContext.Request;
    }
    
    <div class="property-filters-container">
        <div class="property-search-filters @primaryFilterSize" id="searchForm" data-api-key="@globalSettings.GoogleMapsKey" data-channel="@Model.PropertyChannel" data-region-id="@Model.sq.RegionId">
            <div class="container primary-form">
                @if ((int)Model.sq.Channel != 3)
                {
                    <div class="listing-type">
                        <label class="custom-input" for="toBuy">
                            @Html.RadioButtonFor(model => model.sq.BuyOrLet, true, new { @class = "sr-only", @id = "toBuy" })
                            <span class="radio-button"></span>
                            To Buy
                        </label>
                        <label class="custom-input" for="toLet">
                            @Html.RadioButtonFor(m => m.sq.BuyOrLet, false, new { @class = "sr-only", @id = "toLet" })
                            <span class="radio-button"></span>
                            To Let
                        </label>
                    </div>
                }
    

    The issue I am having is that this worked fine in version 8 of Umbraco but now the LINQ statements are not working, they don't seem to access the model content unless using @model instead of inherit but Umbraco then breaks all over if you do that.

    I'm a bit stuck as the other Model. references work just fine

    @Html.RadioButtonFor(m => m.sq.BuyOrLet, false, new { @class = "sr-only", @id = "toLet" })
    

    To reiterate, this worked in V8 with almost the exact same code, now it doesn't in 13. Any help is appreciated!

Please Sign in or register to post replies

Write your reply to:

Draft