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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:11:32+00:00 2026-06-17T03:11:32+00:00

I know similar questions have been asked regarding complex model binding in ASP.NET MVC,

  • 0

I know similar questions have been asked regarding complex model binding in ASP.NET MVC, but I am having a problem binding because of a lack of a sufficient prefix coming back on the POST and wondered if there were an easy solution.

I have a view Model that looks something like this:

public class ViewModel<Survey, Contact>
{
    public Survey Model { get; set; }
    public Contact Model2 { get; set; }
}

I then have an action method like this that accepts the POSTed

public ActionResult Survey(
    string id, string id2, SurveyViewModel<Survey, Contact> model)
{
    // code goes here...
}

In my form, the first two id’s are from the URL route and I then have form code (using @Html.EditorFor(x => x.Model.SurveyName) or similar), generated with names like this:

<input class="text-box single-line" id="Model_Email"
       name="Model.Email" type="text" value="" />

A post works if I change the name from Model.Email to model.Model.Email, but I am trying to avoid having to create a custom model binder.

Is there

  1. A setting I can make in the view to change the name for all fields rendered in a view using the @Html.EditorFor typed view helpers?
  2. Something I can change using the Bind attribute on the action that would allow it to default binding to that object?

The answer may be “build a custom binder”, but I just wanted to pose the question before biting that off.

Thanks for the help. Best Regards,

Hal

  • 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-06-17T03:11:33+00:00Added an answer on June 17, 2026 at 3:11 am

    You can pass custom viewdata with custom HtmlFieldPrefix to view. Every control rendered with helper will have that prefix.

    ViewData.TemplateInfo.HtmlFieldPrefix = "prefix here";
    

    Take a look at this: Forcing EditorFor to prefix input items on view with Class Name?

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

Sidebar

Related Questions

I know similar questions (regarding cherry-picking) have been asked before, but I haven't really
I know similar questions have been asked, e.g. here , but having done a
I know that similar questions have been asked, but having read through them it
I know similar questions have been asked before, but I've tried many times and
I know similar questions have been asked, but I'm not sure about the answers
I know that similar questions have been asked before, but I am very much
I know similar questions have been asked many times. But all I can find
I know that similar questions have been asked all over the place, but I'm
I know a lot of similar questions have been asked, but my case is
I know similar questions have been asked many times befor, but I think this

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.