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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:54:36+00:00 2026-05-10T20:54:36+00:00

Short: how does modelbinding pass objects from view to controller? Long: First, based on

  • 0

Short: how does modelbinding pass objects from view to controller?

Long:
First, based on the parameters given by the user through a search form, some objects are retrieved from the database. These objects are given meta data that are visible(but not defining) to the customer (e.g: naming and pricing of the objects differ from region to region).
Later on in the site, the user can click links that should show details of these objects. Because these meta data are important for displaying, but not defining, I need to get the previously altered object back in the controller. When I use the default asp.net mvc modelbinding, the .ToString() method is used. This off course doesn’t return a relevant string for recreating the complete object.
I would have figured the ISerializable interface would be involved, but this is not so. How should I go about to get the desired effect? I can’t imagine I’m the first one to be faced with this question, so I guess I’m missing something somewhere…

  • 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. 2026-05-10T20:54:36+00:00Added an answer on May 10, 2026 at 8:54 pm

    The default model binding takes form parameters by name and matches them up with the properties of the type specified in the argument list. For example, your model has properties ‘Price’ and ‘Name’, then the form would need to contain inputs with ids/names ‘Price’ and ‘Name’ (I suspect it does a case insensitive match). The binder uses reflection to convert the form values associated with these keys into the appropriate type and assigns it to the properties of a newly created object of the type specified by the parameter (again derived by reflection).

    You can actually look at (and download) the source for this at http://www.codeplex.com/aspnet, although you’ll have to drill down into the MVC source from there. I’d give a link to the DefaultModelBinder source, but the way they are constructed, I believe the link changes as revisions are introduced.

    So, to answer your question, you need to have parameters (could be hidden) on your form that correspond to the properties of the object that you want to recreate. When you POST the form (in the view) to the controller, the binder should reconstitute an object of the specified type using the form parameters. If you need to do translation from the values in the form parameter to the object properties, you’ll probably need to implement your own custom model binder.

    [EDIT] In response to your second post:

    Let’s say that we want to have a link back to an action that uses a customized object. We can store the customized object in TempData (or the Session if we need it to last more through more than one postback) with a particular key. We can then construct the action link and provide the key of the object as value to the ActionLink in an anonymous class. This will pass back the key as a Request parameter. In our action we can use the key from this parameter to retrieve the object from TempData.

    <%= Html.ActionLink( ViewData['CustomObject1',                      'Select',                      new { TempDataKey = ViewData['CustomObject1_Key'] }                    ) %> &nbsp;  public ActionResult Select() {     Entity custObj = null;     string objKey = Request.Params['TempDataKey'];     if (!string.IsNullOrEmpty(objKey))     {        custObj = (Entity)TempData[objKey];     }      ... continue processing } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't think you can do it with inotify. Here… May 11, 2026 at 11:46 pm
  • Editorial Team
    Editorial Team added an answer Check to make sure you have a ServiceReferences.ClientConfig file in… May 11, 2026 at 11:46 pm
  • Editorial Team
    Editorial Team added an answer As John Saunders said, you have to recreate all of… May 11, 2026 at 11:46 pm

Related Questions

I have a short attention span so I couldn't make my way through the
In short: I want to have two fullscreen views, where I can switch between
Our web-based applications has user accounts tied down to users with the passwords specified
In a Silverlight application's log in screen, i need to determine if Caps Lock

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.