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 6945737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:28:28+00:00 2026-05-27T13:28:28+00:00

I have model public class UserModel : IUserModel { public LocationModel WorkLocation { get;

  • 0

I have model

public class UserModel : IUserModel
        {
            public LocationModel WorkLocation { get; set; }
            public LocationModel HomeLocation { get; set; }
            public LocationModel ShippingLocation { get; set; }
    }

I created partial view what show fields from LocationModel class.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<LocationModel>" %>
<fieldset>
    <div class="common-fieldset">
        <div>
            <span class="editor-label">
                <%: Html.LabelFor(model => model.Location.Bldg)%>
            </span><span class="editor-field">
                <%: Html.EditorFor(model => model.Location.Bldg)%>
            </span><span class="editor-label">
                <%: Html.LabelFor(model => model.Location.Lobby)%>
            </span><span class="editor-field">
                <%: Html.EditorFor(model => model.Location.Lobby)%>
            </span><span class="editor-label">
                <%: Html.LabelFor(model => model.Location.Suite)%>
            </span><span class="editor-field">
                <%: Html.EditorFor(model => model.Location.Suite)%>
            </span>
        </div>
    </div>
</fieldset>

When controller render my UserModel evening looks good.
But all fields IDs in HTML from my LocationModel classes have the same name, and on post back LocationModel properties contain not init values. It render each of this property without partial view all working fine. Why ? Thanks.

 <div>
        Home Address:
          <%: Html.Partial("Controls/Location", Model.HomeLocation) %>
        </div>

         <div>
         Work Address:
          <%: Html.Partial("Controls/Location", Model.WorkLocation) %>
        </div>

        <div> Shipping Address:
          <%: Html.Partial("Controls/Location",Model.ShippingLocation) %>
        </div>
  • 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-27T13:28:29+00:00Added an answer on May 27, 2026 at 1:28 pm

    I created partial view what show fields from LocationModel class.

    Instead of using a partial I would recommend you using an editor template. So move this LocationModel.ascx inside ~/Views/Shared/EditorTemplates/LocationModel.ascx and then simply:

    <div>
        Home Address:
        <%= Html.EditorFor(x => x.HomeLocation) %>
    </div>
    
    <div>
        Work Address:
        <%= Html.EditorFor(x => x.WorkLocation) %>
    </div>
    
    <div>
        Shipping Address:
        <%= Html.EditorFor(x => x.ShippingLocation) %>
    </div>
    

    Now all your inputs will have correct ids and names.

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

Sidebar

Related Questions

I have model public class MyModel { public string Name { get; set;} }
I have: 1) public class Model { public String Name { get; set; }
Let's have a model public class Model { public int Number { get; set;
I have this model: public class Package { public string CustomerName { get; set;
I have a model public class Person { public string Name { get; set;
I have a model: public class MyModel { int id { get; set; }
I have a model public class Foo{ public int Id{get;set;} public string Name {get;
i have a model : public class person { public int id{get;set;} public string
I have a view model public class PersonsViewmodel { public string FirstName { get;
I have following model: public class FormularModel { [Required] public string Position { get;

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.