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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:47:58+00:00 2026-05-28T00:47:58+00:00

I have a details page which lets me edit the information associated with a

  • 0

I have a details page which lets me edit the information associated with a particular item.

    public ActionResult Details(int id)
    {
        Call call = db.Calls.Find(id);
        return View(new CallFormViewModel(call));
    }

I use a view model —

public class CallFormViewModel
{
    public Call     Call    { get; private set; }

    public CallFormViewModel()
    {
        Call = new Call();
    }

    public CallFormViewModel(Call call)
    {
        Call = call;
    }
 }

When I submit, I want to only allow certain properties of the ‘call’ object to be updated. My Post handling method looks like this –

    [HttpPost]
    public ActionResult Details(CallFormViewModel callForm)
    {

         (some code removed for clarity)

         UpdateModel(callForm.Call ,new string[] {
            "Contact",
            "Summary",
            "Description",
        }

    }

The problem is that callForm has already been updated with all of the input from the form submit before I even call UpdateModel.

How can I change this and use UpdateModel to selectively update fields?

Thanks

Edit:

I think i’ve been looking at this the wrong way. What I should be doing is this:

    [HttpPost]
    public ActionResult Details(int id, CallFormViewModel callForm)
    {

         var call = db.Calls.Find(id);

         (some code removed for clarity)

         UpdateModel(call, "Call", new string[] {
            "Contact",
            "Summary",
            "Description",
        }

    }

This way it’s taking the incomplete data [and only the fields i want] and applying it to the actual model. I had been confusing the callForm.Call with the actual model object, when infact it’s only a representation of it.

Have to wait till I get to work to test this theory.

  • 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-28T00:47:59+00:00Added an answer on May 28, 2026 at 12:47 am

    When you write your ViewModel in the Action parameters, The Model Binder Bind the ViewModel properties to the “incoming” data. This should work:

    [HttpPost]
    public ActionResult Details()
    {
        CallFormViewModel callForm = new CallFormViewModel();
    
         UpdateModel(callForm.Call ,new string[] {
            "Contact",
            "Summary",
            "Description",
        }
    }
    

    Update:

    The Bind attribute option:

    [Bind(Include = "Contact,Summary,Description")]
    public class CallFormViewModel
    {
        // As before...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which expects a numeric query string value. For example: Details.aspx?rgn=1234
i have function public Menu Details(int? id) { return _dataContext.Menu.Include(ChildMenu).FirstOrDefault(m => m.MenuId == id);
I have a aspx page (details page) that needs to be loaded in a
Scenario: Say I am on an invoice details page. I have a customer name
I have a page that is displaying a company name and its details from
After some advice. I have a client wishing to have an app which lets
I have a page which displays a form that a logged-in user can use
I have a form on my page which gives the user the possibility to
I am using Struts1.3, I have Jsp page which is showing the list of
I have a PHP engine login page which i want to sign in using

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.