Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:56:59+00:00 2026-05-23T14:56:59+00:00

I have a list of Contact objects, from which, I just want a subset

  • 0

I have a list of Contact objects, from which, I just want a subset of attributes. So I used LINQ projection to create an anonymous list and I passed that to a partial view. But when I use that list in partial view, compiler says that it doesn’t have those attributes. I tried the simplest case as follow, but still I have no chance to use an anonymous object or list in a partial view.

var model = new { FirstName = "Saeed", LastName = "Neamati" };
return PartialView(model);

And inside partial view, I have:

<h1>Your name is @Model.FirstName @Model.LastName<h1>

But it says that @Model doesn’t have FirstName and LastName properties. What’s wrong here? When I use @Model, this string would render in browser:

 { Title = "Saeed" }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:56:59+00:00Added an answer on May 23, 2026 at 2:56 pm

    Don’t do this. Don’t pass anonymous objects to your views. Their properties are internal and not visible in other assemblies. Views are dynamically compiled into separate dynamic assemblies by the ASP.NET runtime. So define view models and strongly type your views. Like this:

    public class PersonViewModel
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
    

    and then:

    var model = new PersonViewModel 
    { 
        FirstName = "Saeed", 
        LastName = "Neamati" 
    };
    return PartialView(model);
    

    and in your view:

    @model PersonViewModel
    <h1>Your name is @Model.FirstName @Model.LastName<h1>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this contact list which I'm building using LINQ to SQL. The query
I have create a listview of Contact numbers , the list item contains the
I have two LINQ objects which have exactly the same columns and I would
I have a script that sends emails to a contact list. I would like
I am using grouped tableview for developing a contact list using database. I have
I have a contact picker list with chckboxes of the contacts that have a
So i want to show a contacts list and for that I have transformed
I have list of articles on the page in table and i want to
I am attempting to retrieve a list of objects from Entity Framework via WCF,
In WPF app I have a WCF service which dynamically fills a generic List

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.