Copied to clipboard

Flag this post as spam?

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


  • Gregory 38 posts 128 karma points
    Jan 09, 2023 @ 12:15
    Gregory
    0

    Using URL parameter to pull content matching prevalue of radio button

    I am currently using v7 and I am trying to implement some filtering of content using URL parameter.

    Setting is as follow:

    1. I have a radio button doc type 'Filter Products' added on each node using composition
    2. a URL parameter 'Product'

    On the parent page (list page) Users can select a radio button option and filter content on submit - it then passes the value of the radio button to the URL and reload the page.

    For example, I end up with the following URL:

    https://www.mysite.com/product=pizza
    

    From there I pull the query string on page

    string searchTermProduct = Request.QueryString["Product"];
    

    Adn add a condition to return content where the URL parameter matches the Radio button on the node:

    var brochuresList= Model.BrochureItems.Where(x => x.GetPreValueAsString(x.GetPropertyValue<int>("FilterProducts")) == searchTermProduct);
    

    But no matter what I do I get the following:

    Compiler Error Message: CS1593: Delegate 'System.Func<MyWebsite.Models.PublishedContentModels.BrochureItem,int,bool>' does not take 1 arguments
    

    This works:

    int searchTermProduct = Request.QueryString["Product"].AsInt();
    var brochuresList = Model.BrochureItems.Where(x => x.GetPropertyValue<int>("FilterProducts") == searchTermProduct);
    

    I can get it working using the integer value of the radio button however because I currently have a multi environment setup (dev, staging and prod) those values dont match between environments and as such I would prefer to use the prevalue of the radio button in the condition.

    Any help or pointer would be much appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft