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

  • SEARCH
  • Home
  • 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 4093556
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:37:58+00:00 2026-05-20T19:37:58+00:00

I am learning ASP MVC and I have problem. I have class Company with

  • 0

I am learning ASP MVC and I have problem. I have class Company with an aggregated property:

public class Company
{
    public Company()
    {
        Address = new Address();
    }

    public int Id { get; set; }     
    public string Name { get; set; }
    public virtual Address Address { get; set; }
}

And Address class:

public class Address
{       
    public int Id { get; set; }     
    public string Country { get; set; }
    public string City { get; set; }
    ...
}

How should I write edit for this field? I have tried to create control AddressDetail and pass it to UiHint attribute on Address property, but in view i have additional Id property to edit (!?). When I hide it model state in post is not valid because this property is required.
Another question is how should repository look like for Company? Should it use AddressRepository somehow or write Address by itself?

Maybe somebody have example of that kind of situation?

  • 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-20T19:37:59+00:00Added an answer on May 20, 2026 at 7:37 pm

    As long as the Address class has a parameterless constructor (like your company class), the default mvc modelbinder will have no problem handeling your object. It is not a problem, that both your Company class and Address class has an Id property.

    MVC will by default assign your inputfields with names like ‘Id’ and ‘Address.Id’, which allows for the modelbinder to distinguish between the two properties.

    You could register an editor template for your address class in Global.asax, or you could simple make a partial view and pass it Company.Address in your main view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really like the MVC way and have actually enjoyed learning ASP.NET MVC (I
I am learning ASP.NET MVC now a days and I have found that most
I'm kind of new to the .NET platform. And currently I'm learning ASP.NET MVC.
I have been learning ASP.NET MVC in the last few months and I think
I have just started learning asp.net mvc and one reason of the primary reasons
I have been learning ASP.NET MVC for a few months. I have learned about
I am new to asp.net MVC, using MVC4 at the moment, learning by tutorials
I've been learning the new ASP.NET MVC framwork lately and I've developed a test
I am learning asp.net MVC, as I have been using the sqlconnection, sqlcommands etc
I am writing a learning project in ASP.NET MVC. I have a page Books

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.