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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:39:33+00:00 2026-05-18T20:39:33+00:00

I am pushing out a larger model to a view, but wanting to update

  • 0

I am pushing out a larger model to a view, but wanting to update only parts of that view, that has multiple partial views for a List.

Essentially, I have the code to update the original model, but want to have the ModelState.IsValid operate against the updated original model, not the posted partial.

[HttpPost]
public virtual ActionResult MyAction(MyFullModel sectionUpdates)
{
    var updated = Session['original'] as MyFullModel;
    for (var i=0; i<updated.Section.Count; i++)
    {
        var a = original.Section[i] as SubModel;
        var b = sectionUpdates.Section[i] as SubModel;

        if (String.IsNullOrWhiteSpace(a.Prop1))
        {
            a.Prop1 = b.Prop1
        }
        if (String.IsNullOrWhiteSpace(a.Prop2))
        {
            a.Prop2 = b.Prop2
        }
        ...
    }

    // ??? How do I run ModelState.IsValid against original here ???

    // this doesn't seem to work, the only the posted values are checked...
    //    ViewData.Model = model;
    //    ModelState.Clear();
    //    if (!TryUpdateModel(model))
    //    {
    //        //model state is invalid
    //        return View(secureFlightUpdates);
    //    }

}

I want to run validation against “updated” not “sectionUpdates” above.

I have the original information updating fine, but need to run the validation against the original, not the sectionUpdates.. as if there was already an a.Prop1, there’s no input field in the View for the post. It’s relatively large, and don’t want to post a ton of hidden fields back to the server without need.

  • 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-18T20:39:34+00:00Added an answer on May 18, 2026 at 8:39 pm

    Use this to validate any model:

    var isOriginalModelValid = this.TryValidateModel(updated);
    

    There still might be some fundamental design issues that you have though.

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

Sidebar

Related Questions

I am pushing out a larger model to a view, but wanting to update
Our team has recently been considering pushing out a minor registry fix to users
I'm pushing out an update for an app. I wonder if I can change
I want to swap out one view with another by pushing the old view
Just got this message today on user machines when pushing out an update to
I'm out to write some attached properties as suggested in Pushing read-only GUI properties
We really want to start pushing-out products using the 3.5 framework but it is
I am pushing 2 view controllers in to navigation stack in ApplicationDidFinishLaunching. [navigationController pushViewController:favorites
Im just wondering if I am pushing JSON too far? and if anyone has
How do I stop the table from pushing when the comment field has lots

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.