Resume Templater Project: Create a foreach loop for properties in a list (Task 9)

Link to Learn ASP.NET course Resume Templater project: https://www.codecademy.com/courses/learn-asp-net/projects/razor-project

I am struggling with task 9: In Projects.cshtml you are provided with a <div> container with the class project-container . Wrap the container with a foreach loop and iterate over each project. Access the correct properties in the commented out lines for each project.

I thought that using the placeholdervariable.property would display the data, but it is not.

Here is the code that was provided in the Projects.cshtml.cs

// Projects.cshtml.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using Microsoft.AspNetCore.Mvc;

using Microsoft.AspNetCore.Mvc.RazorPages;

using ResumeTemplater.Models;

namespace ResumeTemplater.Pages

{

  public class ProjectsModel : PageModel

  {

  

    public List<Project> Projects { get; set; }

    

    public string GithubUsername { get; set; }

    

    public void OnGet()

    {

      GithubUsername = "";

      Projects = new List<Project> {

        new Project()

        {

          Title = "Explorella",

          Description = "A large scale travelling application built to help plan your destination and itinerary on your next trip! Built on React, Node, Express, and MongoDB.",

          Year = 2019,

          Technologies = new List<string> {

            "React",

            "Node",

            "Express",

            "MongoDB"

          }

        },

        new Project()

        {

          Title = "Cypher Clothing",

          Description = "A large scale e-commerce clothing store application. Built with Razor Pages and SQLite.",

          Year = 2019,

          Technologies = new List<string> {

            "Razor Pages",

            "SQLite",

          }

        },

        new Project()

        {

          Title = "Password Box",

          Description = "A password manager Chrome plugin used to create and safely store all your passwords! Built with Javascript and HTML.",

          Year = 2020,

          Technologies = new List<string> {

            "Javascript",

            "HTML",

          }

        },

        new Project()

        {

          Title = "Spotivize",

          Description = "Spotivize is a music platform that uses geolocation to track when your favorite artists are playing in your local city! Built with Node, Express, React and MongoDB.",

          Year = 2016,

          Technologies = new List<string> {

            "Express",

            "React",

            "MongoDB"

          }

        }

      };

    }

  }

}

This is what I have added in the Project.cshtml file to try and display the Project Titles.

@page

<!-- Projects.cshtml -->

<!-- Add model directive below -->

@model ProjectsModel

<div class="container">

    @foreach (Project project in Model.Projects)

    {

    <div class="project-container">

      <h4 class="project-title general-header">

        <!--  Project Title --> @project.Title

      </h4>

      <p class="project-year general-header">

        <!--  Project Year -->

      </p>

      <p class="project-description general-content">

        <!--  Project Description -->

      </p>

    </div>

    }

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.