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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:45:21+00:00 2026-05-20T16:45:21+00:00

The issue I am having is when i pass a populated object to a

  • 0

The issue I am having is when i pass a populated object to a view that doesn’t display all of the properties.

public ActionResult Edit(Guid clientID)
{
    Property property = PropertyModel.GetPropertyDetails(clientID);
    return View("Edit", "Site", property);
}

View:

<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<WebFrontend.ViewModels.Property>" %>

<% using (Html.BeginForm())
   {%>
    <%: Html.ValidationSummary(true, "Property update was unsuccessful. Please correct the errors and try again.") %>

    <fieldset>
        <legend>Edit Account: <%: Model.ClientAccountNo %></legend>

         <div class="editor-label">
            <%: Html.LabelFor(model => model.ClientName)%>
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.ClientName)%>
            <%: Html.ValidationMessageFor(model => model.ClientName)%>
        </div>

        <p>
            <input type="submit" value="Update Property" />
        </p>
    </fieldset>

<% } %>

When submitted the Property object is passed to this controller method but all of the properties not used in the view are null or empty including Model.ClientAccountNo which is present on the view before submitting.

[HttpPost]
    public ActionResult Edit(Property property)
    {
        if (ModelState.IsValid)
        {
            bool success = PropertyModel.UpdateProperty(property);
            if (success)
            {
                // property has been updated, take them to the property details screen.
                return RedirectToAction("Details", "Property", new { clientID = property.ClientID });
            }
            else
            {
                ModelState.AddModelError("", "Could not update property.");
                return View("Activate", "Site", property);
            }
        }
        // If we got this far, something failed, redisplay form
        return View("Edit", "Site", property);
    }

I can’t find anything similar on the web, any explanation for why this is happening and how to fix it would be appreciated.

  • 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-20T16:45:22+00:00Added an answer on May 20, 2026 at 4:45 pm

    This is the way MVC works – it tries to construct an object of the action parameter type from the values in the route, form and query string. In your case it can only get the values in the form collection. It does not know anything about the values that you have stored in your database.

    If you are only interested in certain properties you would be better off doing a specific view model with just these on – then you can validate for this specific case.

    If you store values in hidden fields keep in mind that these can be manipulated – if this is a problem definitely go with a specific view model with only the editable fields on.

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

Sidebar

Related Questions

No related questions found

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.